[3666] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 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 |
|
---|
[5275] | 22 | using System;
|
---|
| 23 | using HeuristicLab.Common;
|
---|
[3666] | 24 | using HeuristicLab.Core;
|
---|
| 25 | using HeuristicLab.Data;
|
---|
[4068] | 26 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
[3666] | 27 | using HeuristicLab.Operators;
|
---|
| 28 | using HeuristicLab.Parameters;
|
---|
| 29 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
[4068] | 30 | using HeuristicLab.Problems.DataAnalysis.Evaluators;
|
---|
[3666] | 31 | using HeuristicLab.Problems.DataAnalysis.Symbolic;
|
---|
| 32 |
|
---|
| 33 | namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Analyzers {
|
---|
| 34 | /// <summary>
|
---|
| 35 | /// "An operator to calculate the quality values of a symbolic regression solution symbolic expression tree encoding."
|
---|
| 36 | /// </summary>
|
---|
| 37 | [Item("SymbolicRegressionModelQualityCalculator", "An operator to calculate the quality values of a symbolic regression solution symbolic expression tree encoding.")]
|
---|
| 38 | [StorableClass]
|
---|
[5275] | 39 | [Obsolete("This class should not be used anymore because of performance reasons and will therefore not be updated.")]
|
---|
[3666] | 40 | public sealed class SymbolicRegressionModelQualityCalculator : AlgorithmOperator {
|
---|
| 41 | private const string SymbolicExpressionTreeInterpreterParameterName = "SymbolicExpressionTreeInterpreter";
|
---|
| 42 | private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";
|
---|
| 43 | private const string ProblemDataParameterName = "ProblemData";
|
---|
| 44 | private const string ValuesParameterName = "Values";
|
---|
| 45 | private const string RSQuaredQualityParameterName = "R-squared";
|
---|
| 46 | private const string MeanSquaredErrorQualityParameterName = "Mean Squared Error";
|
---|
| 47 | private const string RelativeErrorQualityParameterName = "Relative Error";
|
---|
| 48 | private const string SamplesStartParameterName = "SamplesStart";
|
---|
| 49 | private const string SamplesEndParameterName = "SamplesEnd";
|
---|
| 50 | private const string UpperEstimationLimitParameterName = "UpperEstimationLimit";
|
---|
| 51 | private const string LowerEstimationLimitParameterName = "LowerEstimationLimit";
|
---|
| 52 |
|
---|
| 53 | #region parameter properties
|
---|
[3710] | 54 | public ILookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
|
---|
| 55 | get { return (ILookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
|
---|
[3683] | 56 | }
|
---|
[3681] | 57 | public IValueLookupParameter<ISymbolicExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter {
|
---|
| 58 | get { return (IValueLookupParameter<ISymbolicExpressionTreeInterpreter>)Parameters[SymbolicExpressionTreeInterpreterParameterName]; }
|
---|
[3666] | 59 | }
|
---|
[3681] | 60 | public IValueLookupParameter<DataAnalysisProblemData> ProblemDataParameter {
|
---|
| 61 | get { return (IValueLookupParameter<DataAnalysisProblemData>)Parameters[ProblemDataParameterName]; }
|
---|
[3666] | 62 | }
|
---|
| 63 | public IValueLookupParameter<IntValue> SamplesStartParameter {
|
---|
| 64 | get { return (IValueLookupParameter<IntValue>)Parameters[SamplesStartParameterName]; }
|
---|
| 65 | }
|
---|
| 66 | public IValueLookupParameter<IntValue> SamplesEndParameter {
|
---|
| 67 | get { return (IValueLookupParameter<IntValue>)Parameters[SamplesEndParameterName]; }
|
---|
| 68 | }
|
---|
| 69 | public IValueLookupParameter<DoubleValue> UpperEstimationLimitParameter {
|
---|
| 70 | get { return (IValueLookupParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; }
|
---|
| 71 | }
|
---|
| 72 | public IValueLookupParameter<DoubleValue> LowerEstimationLimitParameter {
|
---|
| 73 | get { return (IValueLookupParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; }
|
---|
| 74 | }
|
---|
[3681] | 75 | public ILookupParameter<DoubleValue> RSquaredQualityParameter {
|
---|
| 76 | get { return (ILookupParameter<DoubleValue>)Parameters[RSQuaredQualityParameterName]; }
|
---|
[3666] | 77 | }
|
---|
[3681] | 78 | public ILookupParameter<DoubleValue> AverageRelativeErrorQualityParameter {
|
---|
| 79 | get { return (ILookupParameter<DoubleValue>)Parameters[RelativeErrorQualityParameterName]; }
|
---|
[3666] | 80 | }
|
---|
[3681] | 81 | public ILookupParameter<DoubleValue> MeanSquaredErrorQualityParameter {
|
---|
| 82 | get { return (ILookupParameter<DoubleValue>)Parameters[MeanSquaredErrorQualityParameterName]; }
|
---|
[3666] | 83 | }
|
---|
| 84 | #endregion
|
---|
| 85 |
|
---|
[5275] | 86 | [StorableConstructor]
|
---|
| 87 | private SymbolicRegressionModelQualityCalculator(bool deserializing) : base(deserializing) { }
|
---|
| 88 | private SymbolicRegressionModelQualityCalculator(SymbolicRegressionModelQualityCalculator original, Cloner cloner) : base(original, cloner) { }
|
---|
[3666] | 89 | public SymbolicRegressionModelQualityCalculator()
|
---|
| 90 | : base() {
|
---|
[3710] | 91 | Parameters.Add(new LookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree to analyze."));
|
---|
[3681] | 92 | Parameters.Add(new ValueLookupParameter<ISymbolicExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, "The interpreter that should be used to calculate the output values of the symbolic expression tree."));
|
---|
| 93 | Parameters.Add(new ValueLookupParameter<DataAnalysisProblemData>(ProblemDataParameterName, "The problem data containing the input varaibles for the symbolic regression problem."));
|
---|
[3666] | 94 | Parameters.Add(new ValueLookupParameter<IntValue>(SamplesStartParameterName, "The first index of the data set partition on which the model quality values should be calculated."));
|
---|
| 95 | Parameters.Add(new ValueLookupParameter<IntValue>(SamplesEndParameterName, "The first index of the data set partition on which the model quality values should be calculated."));
|
---|
| 96 | Parameters.Add(new ValueLookupParameter<DoubleValue>(UpperEstimationLimitParameterName, "The upper limit that should be used as cut off value for the output values of symbolic expression trees."));
|
---|
| 97 | Parameters.Add(new ValueLookupParameter<DoubleValue>(LowerEstimationLimitParameterName, "The lower limit that should be used as cut off value for the output values of symbolic expression trees."));
|
---|
| 98 | Parameters.Add(new ValueParameter<DoubleMatrix>(ValuesParameterName, "The matrix of original target values and estimated values of the model."));
|
---|
| 99 | Parameters.Add(new ValueLookupParameter<DoubleValue>(MeanSquaredErrorQualityParameterName, "The mean squared error value of the output of the model."));
|
---|
| 100 | Parameters.Add(new ValueLookupParameter<DoubleValue>(RSQuaredQualityParameterName, "The R² correlation coefficient of the output of the model and the original target values."));
|
---|
| 101 | Parameters.Add(new ValueLookupParameter<DoubleValue>(RelativeErrorQualityParameterName, "The average relative percentage error of the output of the model."));
|
---|
[4068] | 102 |
|
---|
[3666] | 103 | #region operator initialization
|
---|
| 104 | SimpleSymbolicRegressionEvaluator simpleEvaluator = new SimpleSymbolicRegressionEvaluator();
|
---|
| 105 | SimpleRSquaredEvaluator simpleR2Evalator = new SimpleRSquaredEvaluator();
|
---|
| 106 | SimpleMeanAbsolutePercentageErrorEvaluator simpleRelErrorEvaluator = new SimpleMeanAbsolutePercentageErrorEvaluator();
|
---|
| 107 | SimpleMSEEvaluator simpleMseEvaluator = new SimpleMSEEvaluator();
|
---|
[3681] | 108 | Assigner clearValues = new Assigner();
|
---|
[3666] | 109 | #endregion
|
---|
| 110 |
|
---|
| 111 | #region parameter wiring
|
---|
| 112 | simpleEvaluator.SymbolicExpressionTreeParameter.ActualName = SymbolicExpressionTreeParameter.Name;
|
---|
| 113 | simpleEvaluator.RegressionProblemDataParameter.ActualName = ProblemDataParameter.Name;
|
---|
| 114 | simpleEvaluator.SamplesStartParameter.ActualName = SamplesStartParameter.Name;
|
---|
| 115 | simpleEvaluator.SamplesEndParameter.ActualName = SamplesEndParameter.Name;
|
---|
| 116 | simpleEvaluator.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameter.Name;
|
---|
| 117 | simpleEvaluator.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameter.Name;
|
---|
| 118 | simpleEvaluator.SymbolicExpressionTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter.Name;
|
---|
| 119 | simpleEvaluator.ValuesParameter.ActualName = ValuesParameterName;
|
---|
| 120 |
|
---|
| 121 | simpleR2Evalator.ValuesParameter.ActualName = ValuesParameterName;
|
---|
| 122 | simpleR2Evalator.RSquaredParameter.ActualName = RSquaredQualityParameter.Name;
|
---|
[3683] | 123 |
|
---|
[3666] | 124 | simpleMseEvaluator.ValuesParameter.ActualName = ValuesParameterName;
|
---|
| 125 | simpleMseEvaluator.MeanSquaredErrorParameter.ActualName = MeanSquaredErrorQualityParameter.Name;
|
---|
[3683] | 126 |
|
---|
[3666] | 127 | simpleRelErrorEvaluator.ValuesParameter.ActualName = ValuesParameterName;
|
---|
| 128 | simpleRelErrorEvaluator.AverageRelativeErrorParameter.ActualName = AverageRelativeErrorQualityParameter.Name;
|
---|
[3681] | 129 |
|
---|
| 130 | clearValues.LeftSideParameter.ActualName = ValuesParameterName;
|
---|
| 131 | clearValues.RightSideParameter.Value = new DoubleMatrix();
|
---|
[3666] | 132 | #endregion
|
---|
| 133 |
|
---|
| 134 | #region operator graph
|
---|
| 135 | OperatorGraph.InitialOperator = simpleEvaluator;
|
---|
| 136 | simpleEvaluator.Successor = simpleR2Evalator;
|
---|
| 137 | simpleR2Evalator.Successor = simpleRelErrorEvaluator;
|
---|
| 138 | simpleRelErrorEvaluator.Successor = simpleMseEvaluator;
|
---|
[3681] | 139 | simpleMseEvaluator.Successor = clearValues;
|
---|
| 140 | clearValues.Successor = null;
|
---|
[3666] | 141 | #endregion
|
---|
| 142 |
|
---|
| 143 | }
|
---|
[5275] | 144 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 145 | return new SymbolicRegressionModelQualityCalculator(this, cloner);
|
---|
| 146 | }
|
---|
[3666] | 147 | }
|
---|
| 148 | }
|
---|