Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9707


Ignore:
Timestamp:
07/16/13 13:51:27 (11 years ago)
Author:
mkommend
Message:

#1837: Adapted sliding window analyzer to reevaluate all individuals if the sliding window gets moved.

Location:
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SlidingWindow
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SlidingWindow/SlidingWindowAnalyzer.cs

    r9164 r9707  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Data;
     25using HeuristicLab.Operators;
     26using HeuristicLab.Optimization;
    2527using HeuristicLab.Parameters;
    2628using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3133  public abstract class SlidingWindowAnalyzer : SymbolicDataAnalysisAnalyzer {
    3234    private const string ProblemDataParameterName = "ProblemData";
     35    private const string EvaluatorParameterName = "Evaluator";
    3336    private const string FitnessCalculationPartitionParameterName = "FitnessCalculationPartition";
    3437    private const string ValidationPartitionParameterName = "ValidationPartition";
     
    6467      get { return (ILookupParameter<BoolValue>)Parameters[TerminateSlidingWindowParameterName]; }
    6568    }
     69    public ILookupParameter<IEvaluator> EvaluatorParameter {
     70      get { return (ILookupParameter<IEvaluator>)Parameters[EvaluatorParameterName]; }
     71    }
    6672    #endregion
    6773
     
    8389      : base() {
    8490      Parameters.Add(new ValueLookupParameter<IDataAnalysisProblemData>(ProblemDataParameterName, "The problem data on which the symbolic data analysis solution should be evaluated."));
     91      Parameters.Add(new LookupParameter<IEvaluator>(EvaluatorParameterName, ""));
    8592      Parameters.Add(new LookupParameter<IntRange>(FitnessCalculationPartitionParameterName, ""));
    8693      Parameters.Add(new LookupParameter<IntRange>(ValidationPartitionParameterName, ""));
     
    9299
    93100      ProblemDataParameter.Hidden = true;
     101    }
     102
     103    [StorableHook(HookType.AfterDeserialization)]
     104    private void AfterDeserialization() {
     105      if (!Parameters.ContainsKey(EvaluatorParameterName))
     106        Parameters.Add(new LookupParameter<IEvaluator>(EvaluatorParameterName, ""));
    94107    }
    95108
     
    115128
    116129      //check if update should be performed or if the algorithm should stop
    117       if (fitnessPartition.End > ProblemDataParameter.ActualValue.TrainingPartition.End)
     130      if (fitnessPartition.End > ProblemDataParameter.ActualValue.TrainingPartition.End) {
    118131        TerminateSlidingWindowParameter.ActualValue.Value = true;
    119       else {
    120         FitnessCalculationPartitionParameter.ActualValue.Start = fitnessPartition.Start;
    121         FitnessCalculationPartitionParameter.ActualValue.End = fitnessPartition.End;
    122         ValidationPartitionParameter.ActualValue.Start = fitnessPartition.End;
    123         ValidationPartitionParameter.ActualValue.End = ValidationPartitionParameter.ActualValue.Start + ValidiationSlidingWindowSize.Value;
     132        return base.Apply();
    124133      }
    125134
    126       return base.Apply();
     135      FitnessCalculationPartitionParameter.ActualValue.Start = fitnessPartition.Start;
     136      FitnessCalculationPartitionParameter.ActualValue.End = fitnessPartition.End;
     137      ValidationPartitionParameter.ActualValue.Start = fitnessPartition.End;
     138      ValidationPartitionParameter.ActualValue.End = ValidationPartitionParameter.ActualValue.Start + ValidiationSlidingWindowSize.Value;
     139
     140      //reevaluate all individuals with new sliding window
     141      UniformSubScopesProcessor subScopesProcessor = new UniformSubScopesProcessor();
     142      subScopesProcessor.Operator = EvaluatorParameter.ActualValue;
     143      subScopesProcessor.Depth.Value = 1;
     144      var operation = ExecutionContext.CreateChildOperation(subScopesProcessor);
     145      var successor = base.Apply();
     146      return new OperationCollection() { operation, successor };
    127147    }
    128148
  • branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SlidingWindow/SlidingWindowVisualizer.cs

    r9162 r9707  
    8585        else throw new NotSupportedException();
    8686
    87         var targetData = ProblemDataParameter.ActualValue.Dataset.GetDoubleValues(targetVariable);
     87        var targetData = ProblemDataParameter.ActualValue.Dataset.GetDoubleValues(targetVariable, ProblemDataParameter.ActualValue.TrainingIndices);
    8888        slidingWindowData = new SlidingWindowData(FitnessCalculationPartitionParameter.ActualValue, targetData);
    8989        results.Add(new Result(SlidingWindowDataResultName, slidingWindowData));
     
    9696        var classificationSolution = trainingSolution as IClassificationSolution;
    9797
    98         if (regressionSolution != null) estimatedValues = regressionSolution.EstimatedValues;
    99         if (classificationSolution != null) estimatedValues = classificationSolution.EstimatedClassValues;
     98        if (regressionSolution != null) estimatedValues = regressionSolution.EstimatedTrainingValues;
     99        if (classificationSolution != null) estimatedValues = classificationSolution.EstimatedTrainingClassValues;
    100100      }
    101101
Note: See TracChangeset for help on using the changeset viewer.