[5557] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[15584] | 3 | * Copyright (C) 2002-2018 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 |
|
---|
| 22 | using HeuristicLab.Common;
|
---|
| 23 | using HeuristicLab.Core;
|
---|
| 24 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
| 25 | using HeuristicLab.Parameters;
|
---|
| 26 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 27 |
|
---|
| 28 | namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification {
|
---|
| 29 | /// <summary>
|
---|
| 30 | /// An operator that analyzes the training best symbolic classification solution for multi objective symbolic classification problems.
|
---|
| 31 | /// </summary>
|
---|
| 32 | [Item("SymbolicClassificationMultiObjectiveTrainingBestSolutionAnalyzer", "An operator that analyzes the training best symbolic classification solution for multi objective symbolic classification problems.")]
|
---|
| 33 | [StorableClass]
|
---|
[5649] | 34 | public sealed class SymbolicClassificationMultiObjectiveTrainingBestSolutionAnalyzer : SymbolicDataAnalysisMultiObjectiveTrainingBestSolutionAnalyzer<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 = "EstimationLimits";
|
---|
| 40 |
|
---|
[5649] | 41 | #region parameter properties
|
---|
| 42 | public ILookupParameter<IClassificationProblemData> ProblemDataParameter {
|
---|
| 43 | get { return (ILookupParameter<IClassificationProblemData>)Parameters[ProblemDataParameterName]; }
|
---|
| 44 | }
|
---|
[8594] | 45 | public IValueLookupParameter<ISymbolicClassificationModelCreator> ModelCreatorParameter {
|
---|
| 46 | get { return (IValueLookupParameter<ISymbolicClassificationModelCreator>)Parameters[ModelCreatorParameterName]; }
|
---|
| 47 | }
|
---|
| 48 | ILookupParameter<ISymbolicClassificationModelCreator> ISymbolicClassificationModelCreatorOperator.ModelCreatorParameter {
|
---|
| 49 | get { return ModelCreatorParameter; }
|
---|
| 50 | }
|
---|
[5649] | 51 | public ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicDataAnalysisTreeInterpreterParameter {
|
---|
| 52 | get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; }
|
---|
| 53 | }
|
---|
[5770] | 54 | public IValueLookupParameter<DoubleLimit> EstimationLimitsParameter {
|
---|
| 55 | get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; }
|
---|
[5720] | 56 | }
|
---|
[5649] | 57 | #endregion
|
---|
[5770] | 58 |
|
---|
[5557] | 59 | [StorableConstructor]
|
---|
| 60 | private SymbolicClassificationMultiObjectiveTrainingBestSolutionAnalyzer(bool deserializing) : base(deserializing) { }
|
---|
| 61 | private SymbolicClassificationMultiObjectiveTrainingBestSolutionAnalyzer(SymbolicClassificationMultiObjectiveTrainingBestSolutionAnalyzer original, Cloner cloner) : base(original, cloner) { }
|
---|
| 62 | public SymbolicClassificationMultiObjectiveTrainingBestSolutionAnalyzer()
|
---|
| 63 | : base() {
|
---|
[5649] | 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 | }
|
---|
| 69 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 70 | return new SymbolicClassificationMultiObjectiveTrainingBestSolutionAnalyzer(this, cloner);
|
---|
| 71 | }
|
---|
| 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 | }
|
---|
| 81 |
|
---|
[5557] | 82 | protected override ISymbolicClassificationSolution CreateSolution(ISymbolicExpressionTree bestTree, double[] bestQuality) {
|
---|
[14027] | 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());
|
---|
[5685] | 88 | }
|
---|
[5557] | 89 | }
|
---|
| 90 | }
|
---|