Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4194 for branches


Ignore:
Timestamp:
08/11/10 13:00:53 (14 years ago)
Author:
gkronber
Message:

Created a feature/exploration branch for new data analysis features #1142

Location:
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression
Files:
8 edited
3 copied

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression-3.3.csproj

    r4065 r4194  
    114114      <SubType>Code</SubType>
    115115    </Compile>
     116    <Compile Include="Symbolic\Evaluators\MultiObjectiveSymbolicVectorRegressionEvaluator.cs" />
     117    <Compile Include="Symbolic\Evaluators\SingleObjectiveSymbolicVectorRegressionEvaluator.cs" />
     118    <Compile Include="Symbolic\Evaluators\PartialDerivativeEvaluator.cs" />
     119    <Compile Include="Symbolic\Evaluators\PartialSymbolicDifferential.cs" />
    116120    <Compile Include="Symbolic\Evaluators\SymbolicRegressionNormalizedMeanSquaredErrorEvaluator.cs">
    117121      <SubType>Code</SubType>
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/Symbolic/Analyzer/ValidationBestScaledSymbolicVectorRegressionSolutionAnalyzer.cs

    r4112 r4194  
    3232using HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression.Symbolic.Evaluators;
    3333using HeuristicLab.Problems.DataAnalysis.Symbolic;
     34using HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression.Symbolic.Interfaces;
    3435
    3536namespace HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression.Symbolic.Analyzers {
     
    4445    private const string SymbolicExpressionTreeInterpreterParameterName = "SymbolicExpressionTreeInterpreter";
    4546    private const string ProblemDataParameterName = "ProblemData";
    46     private const string TrainingSamplesStartParameterName = "TrainingSamplesStart";
    47     private const string TrainingSamplesEndParameterName = "TrainingSamplesEnd";
    4847    private const string ValidationSamplesStartParameterName = "ValidationSamplesStart";
    4948    private const string ValidationSamplesEndParameterName = "ValidationSamplesEnd";
    50     private const string TestSamplesStartParameterName = "TestSamplesStart";
    51     private const string TestSamplesEndParameterName = "TestSamplesEnd";
    52     private const string QualityParameterName = "Quality";
    53     private const string ScaledQualityParameterName = "ScaledQuality";
     49    private const string EvaluatorParameterName = "Evaluator";
     50    private const string MaximizationParameterName = "Maximization";
    5451    private const string UpperEstimationLimitParameterName = "UpperEstimationLimit";
    5552    private const string LowerEstimationLimitParameterName = "LowerEstimationLimit";
     
    8582      get { return (IValueLookupParameter<IntValue>)Parameters[ValidationSamplesEndParameterName]; }
    8683    }
     84    public IValueLookupParameter<ISingleObjectiveSymbolicVectorRegressionEvaluator> EvaluatorParameter {
     85      get { return (IValueLookupParameter<ISingleObjectiveSymbolicVectorRegressionEvaluator>)Parameters[EvaluatorParameterName]; }
     86    }
     87    public IValueLookupParameter<BoolValue> MaximizationParameter {
     88      get { return (IValueLookupParameter<BoolValue>)Parameters[MaximizationParameterName]; }
     89    }
    8790    public IValueLookupParameter<DoubleArray> UpperEstimationLimitParameter {
    8891      get { return (IValueLookupParameter<DoubleArray>)Parameters[UpperEstimationLimitParameterName]; }
     
    119122    public DoubleArray UpperEstimationLimit {
    120123      get { return UpperEstimationLimitParameter.ActualValue; }
     124    }
     125    public ISingleObjectiveSymbolicVectorRegressionEvaluator Evaluator {
     126      get { return EvaluatorParameter.ActualValue; }
     127    }
     128    public BoolValue Maximization {
     129      get { return MaximizationParameter.ActualValue; }
     130    }
     131    public DoubleValue BestSolutionQuality {
     132      get { return BestSolutionQualityParameter.ActualValue; }
    121133    }
    122134    #endregion
     
    131143      Parameters.Add(new ValueLookupParameter<IntValue>(ValidationSamplesStartParameterName, "The first index of the validation partition of the data set."));
    132144      Parameters.Add(new ValueLookupParameter<IntValue>(ValidationSamplesEndParameterName, "The last index of the validation partition of the data set."));
     145      Parameters.Add(new ValueLookupParameter<ISingleObjectiveSymbolicVectorRegressionEvaluator>(EvaluatorParameterName, "The evaluator which should be used to evaluate the solution on the validation set."));
     146      Parameters.Add(new ValueLookupParameter<BoolValue>(MaximizationParameterName, "The direction of optimization."));
    133147      Parameters.Add(new ValueLookupParameter<DoubleArray>(UpperEstimationLimitParameterName, "The upper estimation limit that was set for the evaluation of the symbolic expression trees."));
    134148      Parameters.Add(new ValueLookupParameter<DoubleArray>(LowerEstimationLimitParameterName, "The lower estimation limit that was set for the evaluation of the symbolic expression trees."));
     
    156170      IEnumerable<int> rows = Enumerable.Range(validationStart, validationEnd - validationStart);
    157171      SymbolicExpressionTree bestTree = null;
    158       double bestValidationError = double.PositiveInfinity;
     172      double bestQuality = Maximization.Value ? double.NegativeInfinity : double.PositiveInfinity;
    159173      foreach (var tree in scaledTrees) {
    160         // calculate error on validation set
    161         double validationMse = SymbolicVectorRegressionNormalizedMseEvaluator.Calculate(tree, interpreter, ProblemData, selectedTargetVariables, rows, LowerEstimationLimit, UpperEstimationLimit);
    162         if (bestValidationError > validationMse) {
    163           bestValidationError = validationMse;
     174        // calculate quality on validation set
     175        double quality = Evaluator.Evaluate(tree, interpreter, ProblemData, selectedTargetVariables, rows, LowerEstimationLimit, UpperEstimationLimit);
     176        if ((Maximization.Value && quality > bestQuality) ||
     177            (!Maximization.Value && quality < bestQuality)) {
     178          bestQuality = quality;
    164179          bestTree = tree;
    165180        }
    166181      }
    167       if (BestSolutionQualityParameter.ActualValue == null || BestSolutionQualityParameter.ActualValue.Value > bestValidationError) {
     182      bool newBest =
     183        BestSolutionQualityParameter.ActualValue == null ||
     184        (Maximization.Value && bestQuality > BestSolutionQuality.Value) ||
     185                     (!Maximization.Value && bestQuality < BestSolutionQuality.Value);
     186      if (newBest) {
    168187        var bestSolution = bestTree;
    169188
     
    172191
    173192        BestSolutionParameter.ActualValue = bestSolution;
    174         BestSolutionQualityParameter.ActualValue = new DoubleValue(bestValidationError);
     193        BestSolutionQualityParameter.ActualValue = new DoubleValue(bestQuality);
    175194      }
    176195
     
    185204      results[BestSolutionParameterName].Value = BestSolutionParameter.ActualValue;
    186205      results[BestSolutionQualityParameterName].Value = new DoubleValue(BestSolutionQualityParameter.ActualValue.Value);
    187       results[CurrentBestValidationQualityParameterName].Value = new DoubleValue(bestValidationError);
     206      results[CurrentBestValidationQualityParameterName].Value = new DoubleValue(bestQuality);
    188207
    189208      DataTable validationValues = (DataTable)results[BestSolutionQualityValuesParameterName].Value;
    190209      AddValue(validationValues, BestSolutionQualityParameter.ActualValue.Value, BestSolutionQualityParameterName, BestSolutionQualityParameterName);
    191       AddValue(validationValues, bestValidationError, CurrentBestValidationQualityParameterName, CurrentBestValidationQualityParameterName);
     210      AddValue(validationValues, bestQuality, CurrentBestValidationQualityParameterName, CurrentBestValidationQualityParameterName);
    192211
    193212      return base.Apply();
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/Symbolic/Evaluators/SymbolicVectorRegressionEvaluator.cs

    r4068 r4194  
    105105    #endregion
    106106
     107    public SymbolicVectorRegressionEvaluator(bool deserializing) : base(deserializing) { }
    107108    public SymbolicVectorRegressionEvaluator()
    108109      : base() {
     
    118119    }
    119120
    120     public override IOperation Apply() {
    121       var interpreter = SymbolicExpressionTreeInterpreter;
    122       var tree = SymbolicExpressionTree;
    123       var problemData = MultiVariateDataAnalysisProblemData;
    124 
    125       IEnumerable<string> selectedTargetVariables =
    126         problemData.TargetVariables.CheckedItems
    127         .Select(x => x.Value.Value);
    128 
    129       // check if there is a vector component for each target variable
    130       if (selectedTargetVariables.Count() != tree.Root.SubTrees[0].SubTrees.Count)
    131         throw new ArgumentException("The dimension of the output-vector of the tree doesn't match the number of selected target variables.");
    132       int start = SamplesStart.Value;
    133       int end = SamplesEnd.Value;
    134 
    135       IEnumerable<int> rows = GenerateRowsToEvaluate((uint)Random.Next(), RelativeNumberOfEvaluatedSamples.Value, start, end);
    136 
    137       Evaluate(tree, interpreter, problemData, selectedTargetVariables, rows, LowerEstimationLimit, UpperEstimationLimit);
    138 
    139       return base.Apply();
    140     }
    141 
    142     public abstract void Evaluate(SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter, MultiVariateDataAnalysisProblemData problemData, IEnumerable<string> targetVariables, IEnumerable<int> rows, DoubleArray lowerEstimationBound, DoubleArray upperEstimationBound);
    143 
    144     private static IEnumerable<int> GenerateRowsToEvaluate(uint seed, double relativeAmount, int start, int end) {
     121    public static IEnumerable<int> GenerateRowsToEvaluate(uint seed, double relativeAmount, int start, int end) {
    145122      if (end < start) throw new ArgumentException("Start value is larger than end value.");
    146123      int count = (int)((end - start) * relativeAmount);
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/Symbolic/Evaluators/SymbolicVectorRegressionNormalizedMseEvaluator.cs

    r4112 r4194  
    3434  [Item("SymbolicVectorRegressionNormalizedMseEvaluator", "Represents an operator that calculates the sum of the normalized mean squared error over all components.")]
    3535  [StorableClass]
    36   public class SymbolicVectorRegressionNormalizedMseEvaluator : SymbolicVectorRegressionEvaluator, ISingleObjectiveSymbolicVectorRegressionEvaluator {
    37     private const string QualityParameterName = "ScaledNormalizedMeanSquaredError";
     36  public class SymbolicVectorRegressionNormalizedMseEvaluator : SingleObjectiveSymbolicVectorRegressionEvaluator {
    3837
    39     #region parameter properties
    40     public ILookupParameter<DoubleValue> QualityParameter {
    41       get { return (ILookupParameter<DoubleValue>)Parameters[QualityParameterName]; }
     38
     39    public SymbolicVectorRegressionNormalizedMseEvaluator(bool deserializing) : base(deserializing) { }
     40    public SymbolicVectorRegressionNormalizedMseEvaluator()
     41      : base() {
    4242    }
    4343
    44     #endregion
    45 
    46     public SymbolicVectorRegressionNormalizedMseEvaluator()
    47       : base() {
    48       Parameters.Add(new LookupParameter<DoubleValue>(QualityParameterName, "The sum of the normalized mean squared error over all components of the symbolic vector regression solution encoded as a symbolic expression tree."));
    49     }
    50 
    51     public override void Evaluate(SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter, MultiVariateDataAnalysisProblemData problemData, IEnumerable<string> targetVariables, IEnumerable<int> rows, DoubleArray lowerEstimationBound, DoubleArray upperEstimationBound) {
    52       double nmse = Calculate(tree, interpreter, problemData, targetVariables, rows, lowerEstimationBound, upperEstimationBound);
    53       QualityParameter.ActualValue = new DoubleValue(nmse);
     44    public override double Evaluate(SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter, MultiVariateDataAnalysisProblemData problemData, IEnumerable<string> targetVariables, IEnumerable<int> rows, DoubleArray lowerEstimationBound, DoubleArray upperEstimationBound) {
     45      return Calculate(tree, interpreter, problemData, targetVariables, rows, lowerEstimationBound, upperEstimationBound);
    5446    }
    5547
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/Symbolic/Evaluators/SymbolicVectorRegressionScaledMseEvaluator.cs

    r4112 r4194  
    3434  [Item("SymbolicVectorRegressionScaledMseEvaluator", "Represents an operator that calculates the scaled mean squared error for all components independently.")]
    3535  [StorableClass]
    36   public class SymbolicVectorRegressionScaledMseEvaluator : SymbolicVectorRegressionEvaluator, IMultiObjectiveSymbolicVectorRegressionEvaluator {
    37     private const string QualitiesParameterName = "ScaledMeanSquaredErrors";
     36  public class SymbolicVectorRegressionScaledMseEvaluator : MultiObjectiveSymbolicVectorRegressionEvaluator {
    3837    private const string AlphaParameterName = "Alpha";
    3938    private const string BetaParameterName = "Beta";
    4039
    4140    #region parameter properties
    42     public ILookupParameter<DoubleArray> QualitiesParameter {
    43       get { return (ILookupParameter<DoubleArray>)Parameters[QualitiesParameterName]; }
    44     }
    4541    public ILookupParameter<DoubleArray> AlphaParameter {
    4642      get { return (ILookupParameter<DoubleArray>)Parameters[AlphaParameterName]; }
     
    5450    public SymbolicVectorRegressionScaledMseEvaluator()
    5551      : base() {
    56       Parameters.Add(new LookupParameter<DoubleArray>(QualitiesParameterName, "The mean squared errors for each component of the symbolic vector regression solution encoded as a symbolic expression tree."));
    5752      Parameters.Add(new LookupParameter<DoubleArray>(AlphaParameterName, "The alpha parameter for linear scaling."));
    5853      Parameters.Add(new LookupParameter<DoubleArray>(BetaParameterName, "The beta parameter for linear scaling."));
    5954    }
    6055
    61     public override void Evaluate(SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter, MultiVariateDataAnalysisProblemData problemData, IEnumerable<string> targetVariables, IEnumerable<int> rows, DoubleArray lowerEstimationBound, DoubleArray upperEstimationBound) {
     56    public override double[] Evaluate(SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter, MultiVariateDataAnalysisProblemData problemData, IEnumerable<string> targetVariables, IEnumerable<int> rows, DoubleArray lowerEstimationBound, DoubleArray upperEstimationBound) {
    6257      List<string> targetVariablesList = targetVariables.ToList();
    63       DoubleArray qualities = new DoubleArray(targetVariables.Count());
     58      double[] qualities = new double[targetVariables.Count()];
    6459      DoubleArray alpha = new DoubleArray(qualities.Length);
    6560      DoubleArray beta = new DoubleArray(qualities.Length);
     
    8782      }
    8883
    89       QualitiesParameter.ActualValue = qualities;
    9084      AlphaParameter.ActualValue = alpha;
    9185      BetaParameter.ActualValue = beta;
     86      return qualities;
    9287    }
    9388  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/Symbolic/Evaluators/SymbolicVectorRegressionScaledNormalizedMseEvaluator.cs

    r4112 r4194  
    3434  [Item("SymbolicVectorRegressionScaledNormalizedMseEvaluator", "Represents an operator that calculates the sum of the normalized mean squared error over all components.")]
    3535  [StorableClass]
    36   public class SymbolicVectorRegressionScaledNormalizedMseEvaluator : SymbolicVectorRegressionEvaluator, ISingleObjectiveSymbolicVectorRegressionEvaluator {
    37     private const string QualityParameterName = "ScaledNormalizedMeanSquaredError";
     36  public class SymbolicVectorRegressionScaledNormalizedMseEvaluator : SingleObjectiveSymbolicVectorRegressionEvaluator {
    3837    private const string AlphaParameterName = "Alpha";
    3938    private const string BetaParameterName = "Beta";
    4039
    4140    #region parameter properties
    42     public ILookupParameter<DoubleValue> QualityParameter {
    43       get { return (ILookupParameter<DoubleValue>)Parameters[QualityParameterName]; }
    44     }
    4541    public ILookupParameter<DoubleArray> AlphaParameter {
    4642      get { return (ILookupParameter<DoubleArray>)Parameters[AlphaParameterName]; }
     
    5450    public SymbolicVectorRegressionScaledNormalizedMseEvaluator()
    5551      : base() {
    56       Parameters.Add(new LookupParameter<DoubleValue>(QualityParameterName, "The sum of the normalized mean squared error over all components of the symbolic vector regression solution encoded as a symbolic expression tree."));
    5752      Parameters.Add(new LookupParameter<DoubleArray>(AlphaParameterName, "The alpha parameter for linear scaling."));
    5853      Parameters.Add(new LookupParameter<DoubleArray>(BetaParameterName, "The beta parameter for linear scaling."));
    5954    }
    6055
    61     public override void Evaluate(SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter, MultiVariateDataAnalysisProblemData problemData, IEnumerable<string> targetVariables, IEnumerable<int> rows, DoubleArray lowerEstimationBound, DoubleArray upperEstimationBound) {
     56    public override double Evaluate(SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter, MultiVariateDataAnalysisProblemData problemData, IEnumerable<string> targetVariables, IEnumerable<int> rows, DoubleArray lowerEstimationBound, DoubleArray upperEstimationBound) {
    6257      List<string> targetVariablesList = targetVariables.ToList();
    6358      double nmseSum = 0.0;
     
    8782      AlphaParameter.ActualValue = alpha;
    8883      BetaParameter.ActualValue = beta;
    89       QualityParameter.ActualValue = new DoubleValue(nmseSum);
     84      return nmseSum;
    9085    }
    9186  }
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/Symbolic/Interfaces/IMultiObjectiveSymbolicVectorRegressionEvaluator.cs

    r4068 r4194  
    2525using HeuristicLab.Optimization;
    2626using HeuristicLab.Problems.DataAnalysis.Symbolic;
     27using System.Collections.Generic;
    2728
    2829namespace HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression.Symbolic.Interfaces {
     
    3233    ILookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter { get; }
    3334    ILookupParameter<ISymbolicExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter { get; }
     35
     36    double[] Evaluate(SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter, MultiVariateDataAnalysisProblemData problemData, IEnumerable<string> targetVariables, IEnumerable<int> rows, DoubleArray lowerEstimationBound, DoubleArray upperEstimationBound);
     37
    3438  }
    3539}
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/Symbolic/Interfaces/ISingleObjectiveSymbolicVectorRegressionEvaluator.cs

    r4068 r4194  
    2525using HeuristicLab.Optimization;
    2626using HeuristicLab.Problems.DataAnalysis.Symbolic;
     27using System.Collections.Generic;
    2728
    2829namespace HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression.Symbolic.Interfaces {
     
    3233    ILookupParameter<SymbolicExpressionTree> SymbolicExpressionTreeParameter { get; }
    3334    ILookupParameter<ISymbolicExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter { get; }
     35
     36    double Evaluate(SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter, MultiVariateDataAnalysisProblemData problemData, IEnumerable<string> targetVariables, IEnumerable<int> rows, DoubleArray lowerEstimationBound, DoubleArray upperEstimationBound);
    3437  }
    3538}
Note: See TracChangeset for help on using the changeset viewer.