Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/18/15 10:39:47 (9 years ago)
Author:
gkronber
Message:

#2175: merged all changes from branch to trunk (preserving the original .csproj-files so that I don't have to change reference and output paths)

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression

  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4

    • Property svn:mergeinfo set to (toggle deleted branches)
      /branches/DataAnalysis.ComplexityAnalyzer/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4mergedeligible
      /branches/HLScript/HeuristicLab.Problems.DataAnalysis.Symbolic.Regressionmergedeligible
      /stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regressionmergedeligible
      /branches/Benchmarking/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression6917-7005
      /branches/CloningRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression4656-4721
      /branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression5471-5473
      /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression5815-6180
      /branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression4458-4459,​4462,​4464
      /branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression10085-11101
      /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression6284-6795
      /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression5060
      /branches/HeuristicLab.TreeSimplifier/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression8388-8942
      /branches/LogResidualEvaluator/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression10202-10483
      /branches/NET40/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression5138-5162
      /branches/ParallelEngine/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression5175-5192
      /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression7748-7810
      /branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression6350-6627
      /branches/Restructure trunk solution/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression6828
      /branches/SpectralKernelForGaussianProcesses/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression10204-10479
      /branches/SuccessProgressAnalysis/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression5370-5682
      /branches/Trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression6829-6865
      /branches/VNS/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression5594-5752
      /branches/histogram/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression5959-6341
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer.cs

    r12012 r13241  
    2020#endregion
    2121
     22using System.Collections.Generic;
     23using System.Linq;
     24using HeuristicLab.Analysis;
    2225using HeuristicLab.Common;
    2326using HeuristicLab.Core;
     27using HeuristicLab.Data;
    2428using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     29using HeuristicLab.Optimization;
    2530using HeuristicLab.Parameters;
    2631using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3742    private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter";
    3843    private const string EstimationLimitsParameterName = "EstimationLimits";
     44    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
     45    private const string ValidationPartitionParameterName = "ValidationPartition";
     46
    3947    #region parameter properties
    4048    public ILookupParameter<IRegressionProblemData> ProblemDataParameter {
     
    4755      get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; }
    4856    }
     57    public ILookupParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {
     58      get { return (ILookupParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }
     59    }
     60
     61    public IValueLookupParameter<IntRange> ValidationPartitionParameter {
     62      get { return (IValueLookupParameter<IntRange>)Parameters[ValidationPartitionParameterName]; }
     63    }
    4964    #endregion
    5065
     
    5469    public SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer()
    5570      : base() {
    56       Parameters.Add(new LookupParameter<IRegressionProblemData>(ProblemDataParameterName, "The problem data for the symbolic regression solution."));
    57       Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree."));
    58       Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The lower and upper limit for the estimated values produced by the symbolic regression model."));
     71      Parameters.Add(new LookupParameter<IRegressionProblemData>(ProblemDataParameterName, "The problem data for the symbolic regression solution.") { Hidden = true });
     72      Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree.") { Hidden = true });
     73      Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The lower and upper limit for the estimated values produced by the symbolic regression model.") { Hidden = true });
     74      Parameters.Add(new LookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "Maximal length of the symbolic expression.") { Hidden = true });
     75      Parameters.Add(new ValueLookupParameter<IntRange>(ValidationPartitionParameterName, "The validation partition."));
     76    }
     77
     78    [StorableHook(HookType.AfterDeserialization)]
     79    private void AfterDeserialization() {
     80      if (!Parameters.ContainsKey(MaximumSymbolicExpressionTreeLengthParameterName))
     81        Parameters.Add(new LookupParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, "Maximal length of the symbolic expression.") { Hidden = true });
     82      if (!Parameters.ContainsKey(ValidationPartitionParameterName))
     83        Parameters.Add(new ValueLookupParameter<IntRange>(ValidationPartitionParameterName, "The validation partition."));
    5984    }
    6085
     
    6893      return new SymbolicRegressionSolution(model, (IRegressionProblemData)ProblemDataParameter.ActualValue.Clone());
    6994    }
     95
     96    public override IOperation Apply() {
     97      var operation = base.Apply();
     98      var paretoFront = TrainingBestSolutionsParameter.ActualValue;
     99
     100      IResult result;
     101      ScatterPlot qualityToTreeSize;
     102      if (!ResultCollection.TryGetValue("Pareto Front Analysis", out result)) {
     103        qualityToTreeSize = new ScatterPlot("Quality vs Tree Size", "");
     104        qualityToTreeSize.VisualProperties.XAxisMinimumAuto = false;
     105        qualityToTreeSize.VisualProperties.XAxisMaximumAuto = false;
     106        qualityToTreeSize.VisualProperties.YAxisMinimumAuto = false;
     107        qualityToTreeSize.VisualProperties.YAxisMaximumAuto = false;
     108
     109        qualityToTreeSize.VisualProperties.XAxisMinimumFixedValue = 0;
     110        qualityToTreeSize.VisualProperties.XAxisMaximumFixedValue = MaximumSymbolicExpressionTreeLengthParameter.ActualValue.Value;
     111        qualityToTreeSize.VisualProperties.YAxisMinimumFixedValue = 0;
     112        qualityToTreeSize.VisualProperties.YAxisMaximumFixedValue = 2;
     113        ResultCollection.Add(new Result("Pareto Front Analysis", qualityToTreeSize));
     114      } else {
     115        qualityToTreeSize = (ScatterPlot)result.Value;
     116      }
     117
     118
     119      int previousTreeLength = -1;
     120      var sizeParetoFront = new LinkedList<ISymbolicRegressionSolution>();
     121      foreach (var solution in paretoFront.OrderBy(s => s.Model.SymbolicExpressionTree.Length)) {
     122        int treeLength = solution.Model.SymbolicExpressionTree.Length;
     123        if (!sizeParetoFront.Any()) sizeParetoFront.AddLast(solution);
     124        if (solution.TrainingNormalizedMeanSquaredError < sizeParetoFront.Last.Value.TrainingNormalizedMeanSquaredError) {
     125          if (treeLength == previousTreeLength)
     126            sizeParetoFront.RemoveLast();
     127          sizeParetoFront.AddLast(solution);
     128        }
     129        previousTreeLength = treeLength;
     130      }
     131
     132      qualityToTreeSize.Rows.Clear();
     133      var trainingRow = new ScatterPlotDataRow("Training NMSE", "", sizeParetoFront.Select(x => new Point2D<double>(x.Model.SymbolicExpressionTree.Length, x.TrainingNormalizedMeanSquaredError)));
     134      trainingRow.VisualProperties.PointSize = 8;
     135      qualityToTreeSize.Rows.Add(trainingRow);
     136
     137      var validationPartition = ValidationPartitionParameter.ActualValue;
     138      if (validationPartition.Size != 0) {
     139        var problemData = ProblemDataParameter.ActualValue;
     140        var validationIndizes = Enumerable.Range(validationPartition.Start, validationPartition.Size).ToList();
     141        var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, validationIndizes).ToList();
     142        OnlineCalculatorError error;
     143        var validationRow = new ScatterPlotDataRow("Validation NMSE", "",
     144          sizeParetoFront.Select(x => new Point2D<double>(x.Model.SymbolicExpressionTree.Length,
     145          OnlineNormalizedMeanSquaredErrorCalculator.Calculate(targetValues, x.GetEstimatedValues(validationIndizes), out error))));
     146        validationRow.VisualProperties.PointSize = 7;
     147        qualityToTreeSize.Rows.Add(validationRow);
     148      }
     149
     150      return operation;
     151    }
     152
    70153  }
    71154}
Note: See TracChangeset for help on using the changeset viewer.