Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/07/10 21:10:46 (15 years ago)
Author:
gkronber
Message:

Implemented reviewer comments. #893 (HeuristicLab 3.3.0 application review)

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/HeuristicLab.Problems.DataAnalysis.Regression-3.3.csproj

    r3702 r3710  
    8787    <Compile Include="Properties\AssemblyInfo.cs" />
    8888    <Compile Include="Symbolic\Analyzers\BestSymbolicRegressionSolutionAnalyzer.cs" />
    89     <Compile Include="Symbolic\Analyzers\SymbolicRegressionMeanSquaredErrorCalculator.cs" />
    9089    <Compile Include="Symbolic\Analyzers\ISymbolicRegressionAnalyzer.cs" />
    9190    <Compile Include="Symbolic\Analyzers\SymbolicRegressionModelQualityAnalyzer.cs" />
    92     <Compile Include="Symbolic\Analyzers\SymbolicRegressionModelQualityCalculator.cs" />
     91    <Compile Include="Symbolic\Analyzers\SymbolicRegressionModelQualityCalculator.cs">
     92      <SubType>Code</SubType>
     93    </Compile>
    9394    <Compile Include="Symbolic\Analyzers\SymbolicRegressionSolutionLinearScaler.cs" />
    9495    <Compile Include="Symbolic\Analyzers\SymbolicRegressionVariableFrequencyAnalyzer.cs" />
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/BestSymbolicRegressionSolutionAnalyzer.cs

    r3681 r3710  
    3434using HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols;
    3535using HeuristicLab.Problems.DataAnalysis;
     36using HeuristicLab.Problems.DataAnalysis.Evaluators;
    3637
    3738namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Analyzers {
     
    4849    private const string BestSolutionQualityParameterName = "BestSolutionQuality";
    4950    private const string ResultsParameterName = "Results";
    50 
    51     private const string BestSolutionResultName = "Best Solution (on validiation set)";
    52     private const string BestSolutionInputvariableCountResultName = "Variables Used by Best Solution";
     51    private const string BestSolutionResultName = "Best solution (on validiation set)";
     52    private const string BestSolutionInputvariableCountResultName = "Variables used by best solution";
     53    private const string BestSolutionTrainingRSquared = "Best solution R² (training)";
     54    private const string BestSolutionTestRSquared = "Best solution R² (test)";
     55    private const string BestSolutionTrainingMse = "Best solution mean squared error (training)";
     56    private const string BestSolutionTestMse = "Best solution mean squared error (test)";
     57    private const string BestSolutionTrainingRelativeError = "Best solution average relative error (training)";
     58    private const string BestSolutionTestRelativeError = "Best solution average relative error (test)";
    5359
    5460    public ScopeTreeLookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
     
    112118        results.Add(new Result(BestSolutionResultName, solution));
    113119        results.Add(new Result(BestSolutionInputvariableCountResultName, new IntValue(model.InputVariables.Count())));
     120        #region calculate R2,MSE,Rel Error
     121        double[] trainingValues = problemData.Dataset.GetVariableValues(
     122          problemData.TargetVariable.Value,
     123          problemData.TrainingSamplesStart.Value,
     124          problemData.TrainingSamplesEnd.Value);
     125        double[] testValues = problemData.Dataset.GetVariableValues(
     126          problemData.TargetVariable.Value,
     127          problemData.TestSamplesStart.Value,
     128          problemData.TestSamplesEnd.Value);
     129        double trainingR2 = SimpleRSquaredEvaluator.Calculate(trainingValues, solution.EstimatedTrainingValues);
     130        double testR2 = SimpleRSquaredEvaluator.Calculate(testValues, solution.EstimatedTestValues);
     131        double trainingMse = SimpleMSEEvaluator.Calculate(trainingValues, solution.EstimatedTrainingValues);
     132        double testMse = SimpleMSEEvaluator.Calculate(testValues, solution.EstimatedTestValues);
     133        double trainingRelError = SimpleMeanAbsolutePercentageErrorEvaluator.Calculate(trainingValues, solution.EstimatedTrainingValues);
     134        double testRelError = SimpleMeanAbsolutePercentageErrorEvaluator.Calculate(testValues, solution.EstimatedTestValues);
     135        results.Add(new Result(BestSolutionTrainingRSquared, new DoubleValue(trainingR2)));
     136        results.Add(new Result(BestSolutionTestRSquared, new DoubleValue(testR2)));
     137        results.Add(new Result(BestSolutionTrainingMse, new DoubleValue(trainingMse)));
     138        results.Add(new Result(BestSolutionTestMse, new DoubleValue(testMse)));
     139        results.Add(new Result(BestSolutionTrainingRelativeError, new DoubleValue(trainingRelError)));
     140        results.Add(new Result(BestSolutionTestRelativeError, new DoubleValue(testRelError)));
     141        #endregion
    114142      } else {
    115143        if (BestSolutionQualityParameter.ActualValue.Value > qualities[i].Value) {
     
    120148          results[BestSolutionResultName].Value = solution;
    121149          results[BestSolutionInputvariableCountResultName].Value = new IntValue(model.InputVariables.Count());
     150          #region update R2,MSE, Rel Error
     151          double[] trainingValues = problemData.Dataset.GetVariableValues(
     152            problemData.TargetVariable.Value,
     153            problemData.TrainingSamplesStart.Value,
     154            problemData.TrainingSamplesEnd.Value);
     155          double[] testValues = problemData.Dataset.GetVariableValues(
     156            problemData.TargetVariable.Value,
     157            problemData.TestSamplesStart.Value,
     158            problemData.TestSamplesEnd.Value);
     159          double trainingR2 = SimpleRSquaredEvaluator.Calculate(trainingValues, solution.EstimatedTrainingValues);
     160          double testR2 = SimpleRSquaredEvaluator.Calculate(testValues, solution.EstimatedTestValues);
     161          double trainingMse = SimpleMSEEvaluator.Calculate(trainingValues, solution.EstimatedTrainingValues);
     162          double testMse = SimpleMSEEvaluator.Calculate(testValues, solution.EstimatedTestValues);
     163          double trainingRelError = SimpleMeanAbsolutePercentageErrorEvaluator.Calculate(trainingValues, solution.EstimatedTrainingValues);
     164          double testRelError = SimpleMeanAbsolutePercentageErrorEvaluator.Calculate(testValues, solution.EstimatedTestValues);
     165          results[BestSolutionTrainingRSquared].Value = new DoubleValue(trainingR2);
     166          results[BestSolutionTestRSquared].Value = new DoubleValue(testR2);
     167          results[BestSolutionTrainingMse].Value = new DoubleValue(trainingMse);
     168          results[BestSolutionTestMse].Value = new DoubleValue(testMse);
     169          results[BestSolutionTrainingRelativeError].Value = new DoubleValue(trainingRelError);
     170          results[BestSolutionTestRelativeError].Value = new DoubleValue(testRelError);
     171          #endregion
    122172        }
    123173      }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/SymbolicRegressionModelQualityAnalyzer.cs

    r3683 r3710  
    5151    private const string ResultsParameterName = "Results";
    5252
    53     private const string TrainingMeanSquaredErrorQualityParameterName = "TrainingMeanSquaredError";
    54     private const string MinTrainingMeanSquaredErrorQualityParameterName = "MinTrainingMeanSquaredError";
    55     private const string MaxTrainingMeanSquaredErrorQualityParameterName = "MaxTrainingMeanSquaredError";
    56     private const string AverageTrainingMeanSquaredErrorQualityParameterName = "AverageTrainingMeanSquaredError";
    57     private const string BestTrainingMeanSquaredErrorQualityParameterName = "BestTrainingMeanSquaredError";
    58 
    59     private const string TrainingAverageRelativeErrorQualityParameterName = "TrainingAverageRelativeError";
    60     private const string MinTrainingAverageRelativeErrorQualityParameterName = "MinTrainingAverageRelativeError";
    61     private const string MaxTrainingAverageRelativeErrorQualityParameterName = "MaxTrainingAverageRelativeError";
    62     private const string AverageTrainingAverageRelativeErrorQualityParameterName = "AverageTrainingAverageRelativeError";
    63     private const string BestTrainingAverageRelativeErrorQualityParameterName = "BestTrainingAverageRelativeError";
    64 
    65     private const string TrainingRSquaredQualityParameterName = "TrainingRSquared";
    66     private const string MinTrainingRSquaredQualityParameterName = "MinTrainingRSquared";
    67     private const string MaxTrainingRSquaredQualityParameterName = "MaxTrainingRSquared";
    68     private const string AverageTrainingRSquaredQualityParameterName = "AverageTrainingRSquared";
    69     private const string BestTrainingRSquaredQualityParameterName = "BestTrainingRSquared";
    70 
    71     private const string TestMeanSquaredErrorQualityParameterName = "TestMeanSquaredError";
    72     private const string MinTestMeanSquaredErrorQualityParameterName = "MinTestMeanSquaredError";
    73     private const string MaxTestMeanSquaredErrorQualityParameterName = "MaxTestMeanSquaredError";
    74     private const string AverageTestMeanSquaredErrorQualityParameterName = "AverageTestMeanSquaredError";
    75     private const string BestTestMeanSquaredErrorQualityParameterName = "BestTestMeanSquaredError";
    76 
    77     private const string TestAverageRelativeErrorQualityParameterName = "TestAverageRelativeError";
    78     private const string MinTestAverageRelativeErrorQualityParameterName = "MinTestAverageRelativeError";
    79     private const string MaxTestAverageRelativeErrorQualityParameterName = "MaxTestAverageRelativeError";
    80     private const string AverageTestAverageRelativeErrorQualityParameterName = "AverageTestAverageRelativeError";
    81     private const string BestTestAverageRelativeErrorQualityParameterName = "BestTestAverageRelativeError";
    82 
    83     private const string TestRSquaredQualityParameterName = "TestRSquared";
    84     private const string MinTestRSquaredQualityParameterName = "MinTestRSquared";
    85     private const string MaxTestRSquaredQualityParameterName = "MaxTestRSquared";
    86     private const string AverageTestRSquaredQualityParameterName = "AverageTestRSquared";
    87     private const string BestTestRSquaredQualityParameterName = "BestTestRSquared";
    88 
    89     private const string RSquaredValuesParameterName = "R-squared Values";
    90     private const string MeanSquaredErrorValuesParameterName = "Mean Squared Error Values";
    91     private const string RelativeErrorValuesParameterName = "Average Relative Error Values";
     53    private const string TrainingMeanSquaredErrorQualityParameterName = "Mean squared error (training)";
     54    private const string MinTrainingMeanSquaredErrorQualityParameterName = "Min mean squared error (training)";
     55    private const string MaxTrainingMeanSquaredErrorQualityParameterName = "Max mean squared error (training)";
     56    private const string AverageTrainingMeanSquaredErrorQualityParameterName = "Average mean squared error (training)";
     57    private const string BestTrainingMeanSquaredErrorQualityParameterName = "Best mean squared error (training)";
     58
     59    private const string TrainingAverageRelativeErrorQualityParameterName = "Average relative error (training)";
     60    private const string MinTrainingAverageRelativeErrorQualityParameterName = "Min average relative error (training)";
     61    private const string MaxTrainingAverageRelativeErrorQualityParameterName = "Max average relative error (training)";
     62    private const string AverageTrainingAverageRelativeErrorQualityParameterName = "Average average relative error (training)";
     63    private const string BestTrainingAverageRelativeErrorQualityParameterName = "Best average relative error (training)";
     64
     65    private const string TrainingRSquaredQualityParameterName = "R² (training)";
     66    private const string MinTrainingRSquaredQualityParameterName = "Min R² (training)";
     67    private const string MaxTrainingRSquaredQualityParameterName = "Max R² (training)";
     68    private const string AverageTrainingRSquaredQualityParameterName = "Average R² (training)";
     69    private const string BestTrainingRSquaredQualityParameterName = "Best R² (training)";
     70
     71    private const string TestMeanSquaredErrorQualityParameterName = "Mean squared error (test)";
     72    private const string MinTestMeanSquaredErrorQualityParameterName = "Min mean squared error (test)";
     73    private const string MaxTestMeanSquaredErrorQualityParameterName = "Max mean squared error (test)";
     74    private const string AverageTestMeanSquaredErrorQualityParameterName = "Average mean squared error (test)";
     75    private const string BestTestMeanSquaredErrorQualityParameterName = "Best mean squared error (test)";
     76
     77    private const string TestAverageRelativeErrorQualityParameterName = "Average relative error (test)";
     78    private const string MinTestAverageRelativeErrorQualityParameterName = "Min average relative error (test)";
     79    private const string MaxTestAverageRelativeErrorQualityParameterName = "Max average relative error (test)";
     80    private const string AverageTestAverageRelativeErrorQualityParameterName = "Average average relative error (test)";
     81    private const string BestTestAverageRelativeErrorQualityParameterName = "Best average relative error (test)";
     82
     83    private const string TestRSquaredQualityParameterName = "R² (test)";
     84    private const string MinTestRSquaredQualityParameterName = "Min R² (test)";
     85    private const string MaxTestRSquaredQualityParameterName = "Max R² (test)";
     86    private const string AverageTestRSquaredQualityParameterName = "Average R² (test)";
     87    private const string BestTestRSquaredQualityParameterName = "Best R² (test)";
     88
     89    private const string RSquaredValuesParameterName = "R²";
     90    private const string MeanSquaredErrorValuesParameterName = "Mean squared error";
     91    private const string RelativeErrorValuesParameterName = "Average relative error";
    9292
    9393    private const string TrainingSamplesStartParameterName = "TrainingSamplesStart";
     
    132132
    133133    [Storable]
    134     private SymbolicRegressionModelQualityCalculator trainingQualityCalculator;
    135     [Storable]
    136     private SymbolicRegressionModelQualityCalculator testQualityCalculator;
     134    private UniformSubScopesProcessor subScopesProcessor;
    137135    [Storable]
    138136    private MinAverageMaxValueAnalyzer minAvgMaxTrainingMseAnalyzer;
     
    165163
    166164      #region operator initialization
    167       trainingQualityCalculator = new SymbolicRegressionModelQualityCalculator();
    168       testQualityCalculator = new SymbolicRegressionModelQualityCalculator();
     165      subScopesProcessor = new UniformSubScopesProcessor();
     166      SymbolicRegressionModelQualityCalculator trainingQualityCalculator = new SymbolicRegressionModelQualityCalculator();
     167      SymbolicRegressionModelQualityCalculator testQualityCalculator = new SymbolicRegressionModelQualityCalculator();
    169168      minAvgMaxTrainingMseAnalyzer = new MinAverageMaxValueAnalyzer();
    170169      minAvgMaxTestMseAnalyzer = new MinAverageMaxValueAnalyzer();
     
    178177
    179178      #region parameter wiring
     179      subScopesProcessor.Depth.Value = SymbolicExpressionTreeParameter.Depth;
    180180      trainingQualityCalculator.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameter.Name;
    181181      trainingQualityCalculator.ProblemDataParameter.ActualName = ProblemDataParameter.Name;
     
    184184      trainingQualityCalculator.SymbolicExpressionTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter.Name;
    185185      trainingQualityCalculator.SymbolicExpressionTreeParameter.ActualName = SymbolicExpressionTreeParameter.Name;
    186       trainingQualityCalculator.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth;
    187186      trainingQualityCalculator.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameter.Name;
    188187      trainingQualityCalculator.AverageRelativeErrorQualityParameter.ActualName = TrainingAverageRelativeErrorQualityParameterName;
     
    196195      testQualityCalculator.SymbolicExpressionTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter.Name;
    197196      testQualityCalculator.SymbolicExpressionTreeParameter.ActualName = SymbolicExpressionTreeParameter.Name;
    198       testQualityCalculator.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth;
    199197      testQualityCalculator.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameter.Name;
    200198      testQualityCalculator.AverageRelativeErrorQualityParameter.ActualName = TestAverageRelativeErrorQualityParameterName;
     
    209207      minAvgMaxTrainingMseAnalyzer.ValuesParameter.ActualName = MeanSquaredErrorValuesParameterName;
    210208      minAvgMaxTrainingMseAnalyzer.ResultsParameter.ActualName = ResultsParameter.Name;
     209      minAvgMaxTrainingMseAnalyzer.CollectMinValueInResultsParameter.Value = new BoolValue(false);
     210      minAvgMaxTrainingMseAnalyzer.CollectAverageValueInResultsParameter.Value = new BoolValue(false);
     211      minAvgMaxTrainingMseAnalyzer.CollectMaxValueInResultsParameter.Value = new BoolValue(false);
    211212
    212213      minAvgMaxTestMseAnalyzer.ValueParameter.ActualName = TestMeanSquaredErrorQualityParameterName;
     
    217218      minAvgMaxTestMseAnalyzer.ValuesParameter.ActualName = MeanSquaredErrorValuesParameterName;
    218219      minAvgMaxTestMseAnalyzer.ResultsParameter.ActualName = ResultsParameter.Name;
     220      minAvgMaxTestMseAnalyzer.CollectMinValueInResultsParameter.Value = new BoolValue(false);
     221      minAvgMaxTestMseAnalyzer.CollectAverageValueInResultsParameter.Value = new BoolValue(false);
     222      minAvgMaxTestMseAnalyzer.CollectMaxValueInResultsParameter.Value = new BoolValue(false);
     223
    219224      #endregion
    220225      #region training/test R²
     
    226231      minAvgMaxTrainingRSquaredAnalyzer.ValuesParameter.ActualName = RSquaredValuesParameterName;
    227232      minAvgMaxTrainingRSquaredAnalyzer.ResultsParameter.ActualName = ResultsParameter.Name;
     233      minAvgMaxTrainingRSquaredAnalyzer.CollectMinValueInResultsParameter.Value = new BoolValue(false);
     234      minAvgMaxTrainingRSquaredAnalyzer.CollectAverageValueInResultsParameter.Value = new BoolValue(false);
     235      minAvgMaxTrainingRSquaredAnalyzer.CollectMaxValueInResultsParameter.Value = new BoolValue(false);
     236
    228237
    229238      minAvgMaxTestRSquaredAnalyzer.ValueParameter.ActualName = TestRSquaredQualityParameterName;
     
    234243      minAvgMaxTestRSquaredAnalyzer.ValuesParameter.ActualName = RSquaredValuesParameterName;
    235244      minAvgMaxTestRSquaredAnalyzer.ResultsParameter.ActualName = ResultsParameter.Name;
     245      minAvgMaxTestRSquaredAnalyzer.CollectMinValueInResultsParameter.Value = new BoolValue(false);
     246      minAvgMaxTestRSquaredAnalyzer.CollectAverageValueInResultsParameter.Value = new BoolValue(false);
     247      minAvgMaxTestRSquaredAnalyzer.CollectMaxValueInResultsParameter.Value = new BoolValue(false);
     248
    236249      #endregion
    237250      #region training/test avg. rel. error
     
    243256      minAvgMaxTrainingRelErrorAnalyzer.ValuesParameter.ActualName = RelativeErrorValuesParameterName;
    244257      minAvgMaxTrainingRelErrorAnalyzer.ResultsParameter.ActualName = ResultsParameter.Name;
     258      minAvgMaxTrainingRelErrorAnalyzer.CollectMinValueInResultsParameter.Value = new BoolValue(false);
     259      minAvgMaxTrainingRelErrorAnalyzer.CollectAverageValueInResultsParameter.Value = new BoolValue(false);
     260      minAvgMaxTrainingRelErrorAnalyzer.CollectMaxValueInResultsParameter.Value = new BoolValue(false);
    245261
    246262      minAvgMaxTestRelErrorAnalyzer.ValueParameter.ActualName = TestAverageRelativeErrorQualityParameterName;
     
    251267      minAvgMaxTestRelErrorAnalyzer.ValuesParameter.ActualName = RelativeErrorValuesParameterName;
    252268      minAvgMaxTestRelErrorAnalyzer.ResultsParameter.ActualName = ResultsParameter.Name;
     269      minAvgMaxTestRelErrorAnalyzer.CollectMinValueInResultsParameter.Value = new BoolValue(false);
     270      minAvgMaxTestRelErrorAnalyzer.CollectAverageValueInResultsParameter.Value = new BoolValue(false);
     271      minAvgMaxTestRelErrorAnalyzer.CollectMaxValueInResultsParameter.Value = new BoolValue(false);
    253272      #endregion
    254273      #endregion
    255274
    256275      #region operator graph
    257       OperatorGraph.InitialOperator = trainingQualityCalculator;
     276      OperatorGraph.InitialOperator = subScopesProcessor;
     277      subScopesProcessor.Operator = trainingQualityCalculator;
    258278      trainingQualityCalculator.Successor = testQualityCalculator;
    259       testQualityCalculator.Successor = minAvgMaxTrainingMseAnalyzer;
     279      testQualityCalculator.Successor = null;
     280      subScopesProcessor.Successor = minAvgMaxTrainingMseAnalyzer;
    260281      minAvgMaxTrainingMseAnalyzer.Successor = minAvgMaxTestMseAnalyzer;
    261282      minAvgMaxTestMseAnalyzer.Successor = minAvgMaxTrainingRSquaredAnalyzer;
     
    284305
    285306    private void SymbolicExpressionTreeParameter_DepthChanged(object sender, EventArgs e) {
    286       trainingQualityCalculator.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth;
    287       testQualityCalculator.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth;
     307      subScopesProcessor.Depth.Value = SymbolicExpressionTreeParameter.Depth;
    288308      minAvgMaxTrainingMseAnalyzer.ValueParameter.Depth = SymbolicExpressionTreeParameter.Depth;
    289309      minAvgMaxTrainingRelErrorAnalyzer.ValueParameter.Depth = SymbolicExpressionTreeParameter.Depth;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/SymbolicRegressionModelQualityCalculator.cs

    r3683 r3710  
    5757
    5858    #region parameter properties
    59     public ScopeTreeLookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
    60       get { return (ScopeTreeLookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
     59    public ILookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
     60      get { return (ILookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
    6161    }
    6262    public IValueLookupParameter<ISymbolicExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter {
     
    9191    public SymbolicRegressionModelQualityCalculator()
    9292      : base() {
     93      Parameters.Add(new LookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree to analyze."));
    9394      Parameters.Add(new ValueLookupParameter<ISymbolicExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, "The interpreter that should be used to calculate the output values of the symbolic expression tree."));
    94       Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree to analyze."));
    9595      Parameters.Add(new ValueLookupParameter<DataAnalysisProblemData>(ProblemDataParameterName, "The problem data containing the input varaibles for the symbolic regression problem."));
    9696      Parameters.Add(new ValueLookupParameter<IntValue>(SamplesStartParameterName, "The first index of the data set partition on which the model quality values should be calculated."));
     
    102102      Parameters.Add(new ValueLookupParameter<DoubleValue>(RSQuaredQualityParameterName, "The R² correlation coefficient of the output of the model and the original target values."));
    103103      Parameters.Add(new ValueLookupParameter<DoubleValue>(RelativeErrorQualityParameterName, "The average relative percentage error of the output of the model."));
     104     
    104105      #region operator initialization
    105106      SimpleSymbolicRegressionEvaluator simpleEvaluator = new SimpleSymbolicRegressionEvaluator();
     
    143144
    144145    }
    145 
    146     // need to create custom operations for each solution scope (this has to be adapted on basis of the depth value of SymbolicExpressionTreeParameter)
    147     public override IOperation Apply() {
    148       var scopes = GetScopesOnLevel(ExecutionContext.Scope, SymbolicExpressionTreeParameter.Depth);
    149       OperationCollection operations = new OperationCollection();
    150       foreach (IScope treeScopes in scopes) {
    151         operations.Add(ExecutionContext.CreateChildOperation(OperatorGraph.InitialOperator, treeScopes));
    152       }
    153       if (Successor != null) operations.Add(ExecutionContext.CreateOperation(Successor));
    154       return operations;
    155     }
    156 
    157     private IEnumerable<IScope> GetScopesOnLevel(IScope scope, int d) {
    158       if (d == 0) yield return scope;
    159       else {
    160         foreach (IScope subScope in scope.SubScopes) {
    161           foreach (IScope scopesOfSubScope in GetScopesOnLevel(subScope, d - 1)) {
    162             yield return scopesOfSubScope;
    163           }
    164         }
    165       }
    166     }
    167146  }
    168147}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/SymbolicRegressionSolutionLinearScaler.cs

    r3683 r3710  
    4747    private const string BetaParameterName = "Beta";
    4848
    49     public ScopeTreeLookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
    50       get { return (ScopeTreeLookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
     49    public ILookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter {
     50      get { return (ILookupParameter<SymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
    5151    }
    52     public ScopeTreeLookupParameter<SymbolicExpressionTree> ScaledSymbolicExpressionTreeParameter {
    53       get { return (ScopeTreeLookupParameter<SymbolicExpressionTree>)Parameters[ScaledSymbolicExpressionTreeParameterName]; }
     52    public ILookupParameter<SymbolicExpressionTree> ScaledSymbolicExpressionTreeParameter {
     53      get { return (ILookupParameter<SymbolicExpressionTree>)Parameters[ScaledSymbolicExpressionTreeParameterName]; }
    5454    }
    55     public ScopeTreeLookupParameter<DoubleValue> AlphaParameter {
    56       get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters[AlphaParameterName]; }
     55    public ILookupParameter<DoubleValue> AlphaParameter {
     56      get { return (ILookupParameter<DoubleValue>)Parameters[AlphaParameterName]; }
    5757    }
    58     public ScopeTreeLookupParameter<DoubleValue> BetaParameter {
    59       get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters[BetaParameterName]; }
     58    public ILookupParameter<DoubleValue> BetaParameter {
     59      get { return (ILookupParameter<DoubleValue>)Parameters[BetaParameterName]; }
    6060    }
    6161
    6262    public SymbolicRegressionSolutionLinearScaler()
    6363      : base() {
    64       Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression trees to transform."));
    65       Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(ScaledSymbolicExpressionTreeParameterName, "The resulting symbolic expression trees after transformation."));
    66       Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(AlphaParameterName, "Alpha parameter for linear transformation."));
    67       Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(BetaParameterName, "Beta parameter for linear transformation."));
     64      Parameters.Add(new LookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression trees to transform."));
     65      Parameters.Add(new LookupParameter<SymbolicExpressionTree>(ScaledSymbolicExpressionTreeParameterName, "The resulting symbolic expression trees after transformation."));
     66      Parameters.Add(new LookupParameter<DoubleValue>(AlphaParameterName, "Alpha parameter for linear transformation."));
     67      Parameters.Add(new LookupParameter<DoubleValue>(BetaParameterName, "Beta parameter for linear transformation."));
    6868    }
    6969
    7070    public override IOperation Apply() {
    71       ItemArray<SymbolicExpressionTree> trees = SymbolicExpressionTreeParameter.ActualValue;
    72       ItemArray<DoubleValue> alphas = AlphaParameter.ActualValue;
    73       ItemArray<DoubleValue> betas = BetaParameter.ActualValue;
    74       ItemArray<SymbolicExpressionTree> scaledTrees = new ItemArray<SymbolicExpressionTree>(trees.Length);
    75       for (int i = 0; i < trees.Length; i++) {
    76         var mainBranch = trees[i].Root.SubTrees[0].SubTrees[0];
    77         var scaledMainBranch = MakeSum(MakeProduct(betas[i].Value, mainBranch), alphas[i].Value);
     71      SymbolicExpressionTree tree = SymbolicExpressionTreeParameter.ActualValue;
     72      DoubleValue alpha = AlphaParameter.ActualValue;
     73      DoubleValue beta = BetaParameter.ActualValue;
     74      var mainBranch = tree.Root.SubTrees[0].SubTrees[0];
     75      var scaledMainBranch = MakeSum(MakeProduct(beta.Value, mainBranch), alpha.Value);
    7876
    79         // remove the main branch before cloning to prevent cloning of sub-trees
    80         trees[i].Root.SubTrees[0].RemoveSubTree(0);
    81         var scaledTree = (SymbolicExpressionTree)trees[i].Clone();
    82         // insert main branch into the original tree again
    83         trees[i].Root.SubTrees[0].InsertSubTree(0, mainBranch);
    84         // insert the scaled main branch into the cloned tree
    85         scaledTree.Root.SubTrees[0].InsertSubTree(0, scaledMainBranch);
    86         scaledTrees[i] = scaledTree;
    87       }
    88       ScaledSymbolicExpressionTreeParameter.ActualValue = scaledTrees;
     77      // remove the main branch before cloning to prevent cloning of sub-trees
     78      tree.Root.SubTrees[0].RemoveSubTree(0);
     79      var scaledTree = (SymbolicExpressionTree)tree.Clone();
     80      // insert main branch into the original tree again
     81      tree.Root.SubTrees[0].InsertSubTree(0, mainBranch);
     82      // insert the scaled main branch into the cloned tree
     83      scaledTree.Root.SubTrees[0].InsertSubTree(0, scaledMainBranch);
     84      ScaledSymbolicExpressionTreeParameter.ActualValue = scaledTree;
    8985      return base.Apply();
    9086    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/ValidationBestScaledSymbolicRegressionSolutionAnalyzer.cs

    r3683 r3710  
    5656    private const string AlphaParameterName = "Alpha";
    5757    private const string BetaParameterName = "Beta";
    58     private const string BestSolutionParameterName = "ValidationBestSolution";
    59     private const string BestSolutionQualityParameterName = "ValidationBestSolutionQuality";
     58    private const string BestSolutionParameterName = "Best solution (validation)";
     59    private const string BestSolutionQualityParameterName = "Best solution quality (validation)";
     60    private const string CurrentBestValidationQualityParameterName = "Current best validation quality";
    6061    private const string ResultsParameterName = "Results";
    6162
     
    9192    }
    9293
    93     [Storable]
    94     private BestQualityMemorizer validationQualityMemorizer;
    9594    [Storable]
    9695    private BestSymbolicRegressionSolutionAnalyzer bestSolutionAnalyzer;
    9796    [Storable]
    98     private SymbolicRegressionSolutionLinearScaler linearScaler;
     97    private UniformSubScopesProcessor subScopesProcessor;
    9998    [Storable]
    100     private SymbolicRegressionMeanSquaredErrorCalculator validationMseCalculator;
     99    private BestAverageWorstQualityCalculator bestAvgWorstValidationQualityCalculator;
    101100
    102101    public ValidationBestScaledSymbolicRegressionSolutionAnalyzer()
     
    114113
    115114      #region operator initialization
    116       linearScaler = new SymbolicRegressionSolutionLinearScaler();
    117       validationMseCalculator = new SymbolicRegressionMeanSquaredErrorCalculator();
     115      subScopesProcessor = new UniformSubScopesProcessor();
     116      SymbolicRegressionSolutionLinearScaler linearScaler = new SymbolicRegressionSolutionLinearScaler();
     117      SymbolicRegressionMeanSquaredErrorEvaluator validationMseEvaluator = new SymbolicRegressionMeanSquaredErrorEvaluator();
    118118      bestSolutionAnalyzer = new BestSymbolicRegressionSolutionAnalyzer();
    119       validationQualityMemorizer = new BestQualityMemorizer();
    120       BestAverageWorstQualityCalculator bestAvgWorstValidationQualityCalculator = new BestAverageWorstQualityCalculator();
     119       bestAvgWorstValidationQualityCalculator = new BestAverageWorstQualityCalculator();
    121120      DataTableValuesCollector validationValuesCollector = new DataTableValuesCollector();
    122121      ResultsCollector resultsCollector = new ResultsCollector();
     
    124123
    125124      #region parameter wiring
     125      subScopesProcessor.Depth.Value = SymbolicExpressionTreeParameter.Depth;
     126
    126127      linearScaler.AlphaParameter.ActualName = AlphaParameterName;
    127       linearScaler.AlphaParameter.Depth = SymbolicExpressionTreeParameter.Depth;
    128128      linearScaler.BetaParameter.ActualName = BetaParameterName;
    129       linearScaler.BetaParameter.Depth = SymbolicExpressionTreeParameter.Depth;
    130129      linearScaler.SymbolicExpressionTreeParameter.ActualName = SymbolicExpressionTreeParameter.Name;
    131       linearScaler.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth;
    132130      linearScaler.ScaledSymbolicExpressionTreeParameter.ActualName = ScaledSymbolicExpressionTreeParameterName;
    133       linearScaler.ScaledSymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth;
    134 
    135       validationMseCalculator.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameter.Name;
    136       validationMseCalculator.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameter.Name;
    137       validationMseCalculator.SymbolicExpressionTreeParameter.ActualName = ScaledSymbolicExpressionTreeParameterName;
    138       validationMseCalculator.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth;
    139       validationMseCalculator.SymbolicExpressionTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter.Name;
    140       validationMseCalculator.QualityParameter.ActualName = QualityParameterName;
    141       validationMseCalculator.ProblemDataParameter.ActualName = ProblemDataParameter.Name;
    142       validationMseCalculator.SamplesStartParameter.ActualName = SamplesStartParameter.Name;
    143       validationMseCalculator.SamplesEndParameter.ActualName = SamplesEndParameter.Name;
     131
     132      validationMseEvaluator.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameter.Name;
     133      validationMseEvaluator.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameter.Name;
     134      validationMseEvaluator.SymbolicExpressionTreeParameter.ActualName = ScaledSymbolicExpressionTreeParameterName;
     135      validationMseEvaluator.SymbolicExpressionTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter.Name;
     136      validationMseEvaluator.QualityParameter.ActualName = QualityParameterName;
     137      validationMseEvaluator.RegressionProblemDataParameter.ActualName = ProblemDataParameter.Name;
     138      validationMseEvaluator.SamplesStartParameter.ActualName = SamplesStartParameter.Name;
     139      validationMseEvaluator.SamplesEndParameter.ActualName = SamplesEndParameter.Name;
    144140
    145141      bestSolutionAnalyzer.BestSolutionParameter.ActualName = BestSolutionParameter.Name;
     
    154150      bestSolutionAnalyzer.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameter.Name;
    155151
    156       bestAvgWorstValidationQualityCalculator.AverageQualityParameter.ActualName = "Current Average Validation Quality";
    157       bestAvgWorstValidationQualityCalculator.BestQualityParameter.ActualName = "Current Best Validation Quality";
     152      bestAvgWorstValidationQualityCalculator.AverageQualityParameter.ActualName = "Current average validation quality";
     153      bestAvgWorstValidationQualityCalculator.BestQualityParameter.ActualName = CurrentBestValidationQualityParameterName;
    158154      bestAvgWorstValidationQualityCalculator.MaximizationParameter.Value = new BoolValue(false);
    159155      bestAvgWorstValidationQualityCalculator.QualityParameter.ActualName = QualityParameterName;
    160       bestAvgWorstValidationQualityCalculator.WorstQualityParameter.ActualName = "Current Worst Validation Quality";
    161 
    162       validationQualityMemorizer.BestQualityParameter.ActualName = "Best Validation Quality";
    163       validationQualityMemorizer.QualityParameter.ActualName = QualityParameterName;
    164       validationQualityMemorizer.QualityParameter.Depth = SymbolicExpressionTreeParameter.Depth;
    165 
    166       validationValuesCollector.DataTableParameter.ActualName = "Validation Qualities";
    167       validationValuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Validation Quality", null, "Current Best Validation Quality"));
    168       validationValuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Validation Quality", null, "Best Validation Quality"));
    169 
    170       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Validation Quality", null, "Current Best Validation Quality"));
    171       resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Validation Quality", null, "Best Validation Quality"));
    172       resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Validation Qualities"));
     156      bestAvgWorstValidationQualityCalculator.QualityParameter.Depth = SymbolicExpressionTreeParameter.Depth;
     157      bestAvgWorstValidationQualityCalculator.WorstQualityParameter.ActualName = "Current worst validation quality";
     158
     159      validationValuesCollector.DataTableParameter.ActualName = "Validation quality";
     160      validationValuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>(CurrentBestValidationQualityParameterName, null, CurrentBestValidationQualityParameterName));
     161      validationValuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>(BestSolutionQualityParameter.Name, null, BestSolutionQualityParameter.Name));
     162
     163      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>(CurrentBestValidationQualityParameterName, null, CurrentBestValidationQualityParameterName));
     164      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>(BestSolutionQualityParameter.Name, null, BestSolutionQualityParameter.Name));
     165      resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Validation quality"));
    173166      resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name;
    174167      #endregion
    175168
    176169      #region operator graph
    177       OperatorGraph.InitialOperator = linearScaler;
    178       linearScaler.Successor = validationMseCalculator;
    179       validationMseCalculator.Successor = bestSolutionAnalyzer;
     170      OperatorGraph.InitialOperator = subScopesProcessor;
     171      subScopesProcessor.Operator = linearScaler;
     172      linearScaler.Successor = validationMseEvaluator;
     173      validationMseEvaluator.Successor = null;
     174      subScopesProcessor.Successor = bestSolutionAnalyzer;
    180175      bestSolutionAnalyzer.Successor = bestAvgWorstValidationQualityCalculator;
    181       bestAvgWorstValidationQualityCalculator.Successor = validationQualityMemorizer;
    182       validationQualityMemorizer.Successor = validationValuesCollector;
     176      bestAvgWorstValidationQualityCalculator.Successor = validationValuesCollector;
    183177      validationValuesCollector.Successor = resultsCollector;
    184178      resultsCollector.Successor = null;
     
    203197
    204198    private void SymbolicExpressionTreeParameter_DepthChanged(object sender, EventArgs e) {
    205       validationMseCalculator.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth;
    206       validationQualityMemorizer.QualityParameter.Depth = SymbolicExpressionTreeParameter.Depth;
     199      subScopesProcessor.Depth.Value = SymbolicExpressionTreeParameter.Depth;
    207200      bestSolutionAnalyzer.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth;
    208201      bestSolutionAnalyzer.QualityParameter.Depth = SymbolicExpressionTreeParameter.Depth;
    209       linearScaler.AlphaParameter.Depth = SymbolicExpressionTreeParameter.Depth;
    210       linearScaler.BetaParameter.Depth = SymbolicExpressionTreeParameter.Depth;
    211       linearScaler.SymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth;
    212       linearScaler.ScaledSymbolicExpressionTreeParameter.Depth = SymbolicExpressionTreeParameter.Depth;
     202      bestAvgWorstValidationQualityCalculator.QualityParameter.Depth = SymbolicExpressionTreeParameter.Depth;
    213203    }
    214204  }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionSolution.cs

    r3513 r3710  
    2828using System.Collections.Generic;
    2929using System.Linq;
     30using System.Drawing;
    3031
    3132namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic {
     
    3637  [StorableClass]
    3738  public sealed class SymbolicRegressionSolution : DataAnalysisSolution {
     39    public override Image ItemImage {
     40      get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Function; }
     41    }
    3842    [Storable]
    3943    private SymbolicRegressionModel model;
Note: See TracChangeset for help on using the changeset viewer.