Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5322 for trunk


Ignore:
Timestamp:
01/18/11 14:52:38 (13 years ago)
Author:
gkronber
Message:

Added a switch to turn of linear scaling of best solution to classification analyzers. #1369

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/Analyzer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/Analyzer/TrainingBestSymbolicClassificationSolutionAnalyzer.cs

    r5285 r5322  
    5353    private const string UpperEstimationLimitParameterName = "UpperEstimationLimit";
    5454    private const string LowerEstimationLimitParameterName = "LowerEstimationLimit";
     55    private const string ApplyLinearScalingParameterName = "ApplyLinearScaling";
    5556    private const string BestSolutionParameterName = "Best training solution";
    5657    private const string BestSolutionQualityParameterName = "Best training solution quality";
     
    9697      get { return (IValueLookupParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; }
    9798    }
     99    public IValueLookupParameter<BoolValue> ApplyLinearScalingParameter {
     100      get { return (IValueLookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; }
     101    }
    98102
    99103    public ILookupParameter<SymbolicClassificationSolution> BestSolutionParameter {
     
    170174      get { return LowerEstimationLimitParameter.ActualValue; }
    171175    }
     176    public BoolValue ApplyLinearScaling {
     177      get { return ApplyLinearScalingParameter.ActualValue; }
     178      set { ApplyLinearScalingParameter.ActualValue = value; }
     179    }
     180
    172181    public ResultCollection Results {
    173182      get { return ResultsParameter.ActualValue; }
     
    241250      Parameters.Add(new ValueLookupParameter<DoubleValue>(UpperEstimationLimitParameterName, "The upper estimation limit that was set for the evaluation of the symbolic expression trees."));
    242251      Parameters.Add(new ValueLookupParameter<DoubleValue>(LowerEstimationLimitParameterName, "The lower estimation limit that was set for the evaluation of the symbolic expression trees."));
     252      Parameters.Add(new ValueLookupParameter<BoolValue>(ApplyLinearScalingParameterName, "The switch determines if the best solution should be linearly scaled on the whole training set.", new BoolValue(false)));
    243253      Parameters.Add(new LookupParameter<SymbolicClassificationSolution>(BestSolutionParameterName, "The best symbolic classification solution."));
    244254      Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionQualityParameterName, "The quality of the best symbolic classification solution."));
     
    257267    }
    258268
     269    [StorableHook(HookType.AfterDeserialization)]
     270    private void AfterDeserialization() {
     271      if (!Parameters.ContainsKey(ApplyLinearScalingParameterName)) {
     272        Parameters.Add(new ValueLookupParameter<BoolValue>(ApplyLinearScalingParameterName, "The switch determines if the best solution should be linearly scaled on the whole training set.", new BoolValue(false)));
     273      }
     274    }
     275
    259276    public override IDeepCloneable Clone(Cloner cloner) {
    260277      return new TrainingBestSymbolicClassificationSolutionAnalyzer(this, cloner);
     
    287304        string targetVariable = ProblemData.TargetVariable.Value;
    288305
    289         // calculate scaling parameters and only for the best tree using the full training set
    290         double alpha, beta;
    291         SymbolicRegressionScaledMeanSquaredErrorEvaluator.Calculate(SymbolicExpressionTreeInterpreter, bestTree,
    292           lowerEstimationLimit, upperEstimationLimit,
    293           ProblemData.Dataset, targetVariable,
    294           ProblemData.TrainingIndizes, out beta, out alpha);
    295 
    296         // scale tree for solution
    297         var scaledTree = SymbolicRegressionSolutionLinearScaler.Scale(bestTree, alpha, beta);
     306        if (ApplyLinearScaling.Value) {
     307          // calculate scaling parameters and only for the best tree using the full training set
     308          double alpha, beta;
     309          SymbolicRegressionScaledMeanSquaredErrorEvaluator.Calculate(SymbolicExpressionTreeInterpreter, bestTree,
     310            lowerEstimationLimit, upperEstimationLimit,
     311            ProblemData.Dataset, targetVariable,
     312            ProblemData.TrainingIndizes, out beta, out alpha);
     313
     314          // scale tree for solution
     315          bestTree = SymbolicRegressionSolutionLinearScaler.Scale(bestTree, alpha, beta);
     316        }
    298317        var model = new SymbolicRegressionModel((ISymbolicExpressionTreeInterpreter)SymbolicExpressionTreeInterpreter.Clone(),
    299           scaledTree);
     318          bestTree);
    300319        var solution = new SymbolicClassificationSolution((ClassificationProblemData)ProblemData.Clone(), model, lowerEstimationLimit, upperEstimationLimit);
    301320        solution.Name = BestSolutionParameterName;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/Analyzer/ValidationBestSymbolicClassificationSolutionAnalyzer.cs

    r5271 r5322  
    5353    private const string LowerEstimationLimitParameterName = "LowerEstimationLimit";
    5454    private const string CalculateSolutionComplexityParameterName = "CalculateSolutionComplexity";
     55    private const string ApplyLinearScalingParameterName = "ApplyLinearScaling";
    5556
    5657    private const string ResultsParameterName = "Results";
     
    7980      get { return (IValueLookupParameter<ISymbolicExpressionTreeInterpreter>)Parameters[SymbolicExpressionTreeInterpreterParameterName]; }
    8081    }
    81 
    8282    public ILookupParameter<ClassificationProblemData> ClassificationProblemDataParameter {
    8383      get { return (ILookupParameter<ClassificationProblemData>)Parameters[ClassificationProblemDataParameterName]; }
     
    101101      get { return (IValueLookupParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; }
    102102    }
     103    public IValueLookupParameter<BoolValue> ApplyLinearScalingParameter {
     104      get { return (IValueLookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; }
     105    }
    103106    public ILookupParameter<DataTable> VariableFrequenciesParameter {
    104107      get { return (ILookupParameter<DataTable>)Parameters[VariableFrequenciesParameterName]; }
     
    107110      get { return (IValueParameter<BoolValue>)Parameters[CalculateSolutionComplexityParameterName]; }
    108111    }
     112
    109113    public ILookupParameter<ResultCollection> ResultsParameter {
    110114      get { return (ILookupParameter<ResultCollection>)Parameters[ResultsParameterName]; }
     
    166170    public DoubleValue LowerEstimationLimit {
    167171      get { return LowerEstimationLimitParameter.ActualValue; }
     172    }
     173    public BoolValue ApplyLinearScaling {
     174      get { return ApplyLinearScalingParameter.ActualValue; }
     175      set { ApplyLinearScalingParameter.ActualValue = value; }
    168176    }
    169177    public DataTable VariableFrequencies {
     
    216224      Parameters.Add(new ScopeTreeLookupParameter<SymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression trees to analyze."));
    217225      Parameters.Add(new ValueLookupParameter<ISymbolicExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, "The interpreter that should be used for the analysis of symbolic expression trees."));
    218 
    219226      Parameters.Add(new LookupParameter<ClassificationProblemData>(ClassificationProblemDataParameterName, "The problem data for which the symbolic expression tree is a solution."));
    220227      Parameters.Add(new LookupParameter<ISymbolicClassificationEvaluator>(EvaluatorParameterName, "The evaluator which should be used to evaluate the solution on the validation set."));
     
    226233      Parameters.Add(new LookupParameter<DataTable>(VariableFrequenciesParameterName, "The variable frequencies table to use for the calculation of variable impacts"));
    227234      Parameters.Add(new ValueParameter<BoolValue>(CalculateSolutionComplexityParameterName, "Determines if the length and height of the validation best solution should be calculated.", new BoolValue(true)));
     235      Parameters.Add(new ValueLookupParameter<BoolValue>(ApplyLinearScalingParameterName, "The switch determines if the best solution should be linearly scaled on the whole training set.", new BoolValue(false)));
     236
    228237      Parameters.Add(new ValueLookupParameter<ResultCollection>(ResultsParameterName, "The results collection where the analysis values should be stored."));
    229238      Parameters.Add(new LookupParameter<DoubleValue>(BestValidationQualityParameterName, "The validation quality of the best solution in the current run."));
     
    245254      if (!Parameters.ContainsKey(BestSolutionHeightParameterName)) {
    246255        Parameters.Add(new LookupParameter<IntValue>(BestSolutionHeightParameterName, "The height of the best symbolic classification solution."));
     256      }
     257      if (!Parameters.ContainsKey(ApplyLinearScalingParameterName)) {
     258        Parameters.Add(new ValueLookupParameter<BoolValue>(ApplyLinearScalingParameterName, "The switch determines if the best solution should be linearly scaled on the whole training set.", new BoolValue(false)));
    247259      }
    248260    }
     
    289301        (!Maximization.Value && bestQuality < BestValidationQuality.Value);
    290302      if (newBest) {
    291         double alpha, beta;
    292         SymbolicRegressionScaledMeanSquaredErrorEvaluator.Calculate(SymbolicExpressionTreeInterpreter, bestTree,
    293           lowerEstimationLimit, upperEstimationLimit,
    294           ClassificationProblemData.Dataset, targetVariable,
    295           ClassificationProblemData.TrainingIndizes, out beta, out alpha);
    296 
    297         // scale tree for solution
    298         var scaledTree = SymbolicRegressionSolutionLinearScaler.Scale(bestTree, alpha, beta);
     303        if (ApplyLinearScaling.Value) {
     304          double alpha, beta;
     305          SymbolicRegressionScaledMeanSquaredErrorEvaluator.Calculate(SymbolicExpressionTreeInterpreter, bestTree,
     306            lowerEstimationLimit, upperEstimationLimit,
     307            ClassificationProblemData.Dataset, targetVariable,
     308            ClassificationProblemData.TrainingIndizes, out beta, out alpha);
     309
     310          // scale tree for solution
     311          bestTree = SymbolicRegressionSolutionLinearScaler.Scale(bestTree, alpha, beta);
     312        }
    299313        var model = new SymbolicRegressionModel((ISymbolicExpressionTreeInterpreter)SymbolicExpressionTreeInterpreter.Clone(),
    300           scaledTree);
     314          bestTree);
    301315
    302316        if (BestValidationSolution == null) {
Note: See TracChangeset for help on using the changeset viewer.