Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectiveTrainingBestSolutionAnalyzer.cs @ 16829

Last change on this file since 16829 was 16565, checked in by gkronber, 6 years ago

#2520: merged changes from PersistenceOverhaul branch (r16451:16564) into trunk

File size: 5.7 KB
RevLine 
[5557]1#region License Information
2/* HeuristicLab
[16565]3 * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[5557]4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using HeuristicLab.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
25using HeuristicLab.Parameters;
[16565]26using HEAL.Attic;
[5557]27
28namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification {
29  /// <summary>
30  /// An operator that analyzes the training best symbolic classification solution for single objective symbolic classification problems.
31  /// </summary>
32  [Item("SymbolicClassificationSingleObjectiveTrainingBestSolutionAnalyzer", "An operator that analyzes the training best symbolic classification solution for single objective symbolic classification problems.")]
[16565]33  [StorableType("1E179E22-DD6C-4914-8FAA-AB8F7F9B7F7F")]
[5649]34  public sealed class SymbolicClassificationSingleObjectiveTrainingBestSolutionAnalyzer : SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer<ISymbolicClassificationSolution>,
[8594]35    ISymbolicDataAnalysisInterpreterOperator, ISymbolicDataAnalysisBoundedOperator, ISymbolicClassificationModelCreatorOperator {
[5649]36    private const string ProblemDataParameterName = "ProblemData";
[8594]37    private const string ModelCreatorParameterName = "ModelCreator";
[5649]38    private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter";
[5770]39    private const string EstimationLimitsParameterName = "UpperEstimationLimit";
[5649]40    #region parameter properties
41    public ILookupParameter<IClassificationProblemData> ProblemDataParameter {
42      get { return (ILookupParameter<IClassificationProblemData>)Parameters[ProblemDataParameterName]; }
43    }
[8594]44    public IValueLookupParameter<ISymbolicClassificationModelCreator> ModelCreatorParameter {
45      get { return (IValueLookupParameter<ISymbolicClassificationModelCreator>)Parameters[ModelCreatorParameterName]; }
46    }
47    ILookupParameter<ISymbolicClassificationModelCreator> ISymbolicClassificationModelCreatorOperator.ModelCreatorParameter {
48      get { return ModelCreatorParameter; }
49    }
[5649]50    public ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicDataAnalysisTreeInterpreterParameter {
51      get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; }
52    }
[5770]53    public IValueLookupParameter<DoubleLimit> EstimationLimitsParameter {
54      get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; }
[5720]55    }
[5649]56    #endregion
[5720]57
[8664]58
[5557]59    [StorableConstructor]
[16565]60    private SymbolicClassificationSingleObjectiveTrainingBestSolutionAnalyzer(StorableConstructorFlag _) : base(_) { }
[5557]61    private SymbolicClassificationSingleObjectiveTrainingBestSolutionAnalyzer(SymbolicClassificationSingleObjectiveTrainingBestSolutionAnalyzer original, Cloner cloner) : base(original, cloner) { }
62    public SymbolicClassificationSingleObjectiveTrainingBestSolutionAnalyzer()
63      : base() {
[5685]64      Parameters.Add(new LookupParameter<IClassificationProblemData>(ProblemDataParameterName, "The problem data for the symbolic classification solution."));
[8594]65      Parameters.Add(new ValueLookupParameter<ISymbolicClassificationModelCreator>(ModelCreatorParameterName, ""));
[5685]66      Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree."));
[5770]67      Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The lower and upper limit for the estimated values produced by the symbolic classification model."));
[5557]68    }
[8594]69
[5557]70    public override IDeepCloneable Clone(Cloner cloner) {
71      return new SymbolicClassificationSingleObjectiveTrainingBestSolutionAnalyzer(this, cloner);
72    }
[8594]73    [StorableHook(HookType.AfterDeserialization)]
74    private void AfterDeserialization() {
[8883]75      // BackwardsCompatibility3.4
76      #region Backwards compatible code, remove with 3.5
[8594]77      if (!Parameters.ContainsKey(ModelCreatorParameterName))
78        Parameters.Add(new ValueLookupParameter<ISymbolicClassificationModelCreator>(ModelCreatorParameterName, ""));
[8883]79      #endregion
[8594]80    }
[5557]81
82    protected override ISymbolicClassificationSolution CreateSolution(ISymbolicExpressionTree bestTree, double bestQuality) {
[13941]83      var model = ModelCreatorParameter.ActualValue.CreateSymbolicClassificationModel(ProblemDataParameter.ActualValue.TargetVariable, (ISymbolicExpressionTree)bestTree.Clone(), SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper);
[8972]84      if (ApplyLinearScalingParameter.ActualValue.Value) model.Scale(ProblemDataParameter.ActualValue);
[8531]85
[8594]86      model.RecalculateModelParameters(ProblemDataParameter.ActualValue, ProblemDataParameter.ActualValue.TrainingIndices);
87      return model.CreateClassificationSolution((IClassificationProblemData)ProblemDataParameter.ActualValue.Clone());
[5557]88    }
89  }
90}
Note: See TracBrowser for help on using the repository browser.