Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/23/10 14:28:07 (14 years ago)
Author:
gkronber
Message:

Added upper and lower estimation limits. #938 (Data types and operators for regression problems)

File:
1 edited

Legend:

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

    r3462 r3513  
    4040  public sealed class BestValidationSymbolicRegressionSolutionVisualizer : SingleSuccessorOperator, ISingleObjectiveSolutionsVisualizer, ISolutionsVisualizer {
    4141    private const string SymbolicExpressionTreeInterpreterParameterName = "SymbolicExpressionTreeInterpreter";
     42    private const string UpperEstimationLimitParameterName = "UpperEstimationLimit";
     43    private const string LowerEstimationLimitParameterName = "LowerEstimationLimit";
    4244    private const string SymbolicRegressionModelParameterName = "SymbolicRegressionModel";
    4345    private const string DataAnalysisProblemDataParameterName = "DataAnalysisProblemData";
     
    5153    public ILookupParameter<ISymbolicExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter {
    5254      get { return (ILookupParameter<ISymbolicExpressionTreeInterpreter>)Parameters[SymbolicExpressionTreeInterpreterParameterName]; }
     55    }
     56    public IValueLookupParameter<DoubleValue> UpperEstimationLimitParameter {
     57      get { return (IValueLookupParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; }
     58    }
     59    public IValueLookupParameter<DoubleValue> LowerEstimationLimitParameter {
     60      get { return (IValueLookupParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; }
    5361    }
    5462    public IValueLookupParameter<IntValue> ValidationSamplesStartParameter {
     
    8593      get { return SymbolicExpressionTreeInterpreterParameter.ActualValue; }
    8694    }
     95    public DoubleValue UpperEstimationLimit {
     96      get { return UpperEstimationLimitParameter.ActualValue; }
     97    }
     98    public DoubleValue LowerEstimationLimit {
     99      get { return LowerEstimationLimitParameter.ActualValue; }
     100    }
    87101    public IntValue ValidationSamplesStart {
    88102      get { return ValidationSamplesStartParameter.ActualValue; }
     
    99113      Parameters.Add(new LookupParameter<DataAnalysisProblemData>(DataAnalysisProblemDataParameterName, "The symbolic regression problme data on which the best solution should be evaluated."));
    100114      Parameters.Add(new LookupParameter<ISymbolicExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, "The interpreter that should be used to calculate the output values of symbolic expression trees."));
     115      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."));
     116      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."));
    101117      Parameters.Add(new ValueLookupParameter<IntValue>(ValidationSamplesStartParameterName, "The start index of the validation partition (part of the training partition)."));
    102118      Parameters.Add(new ValueLookupParameter<IntValue>(ValidationSamplesEndParameterName, "The end index of the validation partition (part of the training partition)."));
     
    112128      int validationSamplesEnd = ValidationSamplesEnd.Value;
    113129      var validationValues = problemData.Dataset.GetVariableValues(problemData.TargetVariable.Value, validationSamplesStart, validationSamplesEnd);
    114 
     130      double upperEstimationLimit = UpperEstimationLimit.Value;
     131      double lowerEstimationLimit = LowerEstimationLimit.Value;
    115132      var currentBestExpression = (from expression in expressions
    116133                                   let validationQuality =
    117134                                     SymbolicRegressionMeanSquaredErrorEvaluator.Calculate(
    118135                                       SymbolicExpressionTreeInterpreter, expression,
     136                                       lowerEstimationLimit, upperEstimationLimit,
    119137                                       problemData.Dataset, problemData.TargetVariable.Value,
    120138                                       validationSamplesStart, validationSamplesEnd)
     
    126144      if (bestOfRunSolution == null) {
    127145        // no best of run solution yet -> make a solution from the currentBestExpression
    128         UpdateBestOfRunSolution(problemData, currentBestExpression.Expression, SymbolicExpressionTreeInterpreter);
     146        UpdateBestOfRunSolution(problemData, currentBestExpression.Expression, SymbolicExpressionTreeInterpreter, lowerEstimationLimit, upperEstimationLimit);
    129147      } else {
    130148        // compare quality of current best with best of run solution
     
    132150        var bestOfRunValidationQuality = SimpleMSEEvaluator.Calculate(validationValues, estimatedValidationValues);
    133151        if (bestOfRunValidationQuality > currentBestExpression.ValidationQuality) {
    134           UpdateBestOfRunSolution(problemData, currentBestExpression.Expression, SymbolicExpressionTreeInterpreter);
     152          UpdateBestOfRunSolution(problemData, currentBestExpression.Expression, SymbolicExpressionTreeInterpreter, lowerEstimationLimit, upperEstimationLimit);
    135153        }
    136154      }
     
    140158    }
    141159
    142     private void UpdateBestOfRunSolution(DataAnalysisProblemData problemData, SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter) {
    143       var newBestSolution = CreateDataAnalysisSolution(problemData, tree, interpreter);
     160    private void UpdateBestOfRunSolution(DataAnalysisProblemData problemData, SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter,
     161      double lowerEstimationLimit, double upperEstimationLimit) {
     162      var newBestSolution = CreateDataAnalysisSolution(problemData, tree, interpreter, lowerEstimationLimit, upperEstimationLimit);
    144163      if (BestValidationSolutionParameter.ActualValue == null)
    145164        BestValidationSolutionParameter.ActualValue = newBestSolution;
     
    169188    }
    170189
    171     private SymbolicRegressionSolution CreateDataAnalysisSolution(DataAnalysisProblemData problemData, SymbolicExpressionTree expression, ISymbolicExpressionTreeInterpreter interpreter) {
     190    private SymbolicRegressionSolution CreateDataAnalysisSolution(DataAnalysisProblemData problemData, SymbolicExpressionTree expression, ISymbolicExpressionTreeInterpreter interpreter,
     191      double lowerEstimationLimit, double upperEstimationLimit) {
    172192      var model = new SymbolicRegressionModel(interpreter, expression, problemData.InputVariables.Select(s => s.Value));
    173       return new SymbolicRegressionSolution(problemData, model);
     193      return new SymbolicRegressionSolution(problemData, model, lowerEstimationLimit, upperEstimationLimit);
    174194    }
    175195  }
Note: See TracChangeset for help on using the changeset viewer.