Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/28/12 13:11:15 (12 years ago)
Author:
mkommend
Message:

#1919: Refactored calculation of thresholds for SymbolicDiscriminantFunctionClassficationModels and removed the automatic recalculation of thresholds during solution creation.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/MultiObjective/SymbolicClassificationMultiObjectiveTrainingBestSolutionAnalyzer.cs

    r7259 r8531  
    7777    protected override ISymbolicClassificationSolution CreateSolution(ISymbolicExpressionTree bestTree, double[] bestQuality) {
    7878      var model = new SymbolicDiscriminantFunctionClassificationModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper);
    79       if (ApplyLinearScaling.Value) {
    80         SymbolicDiscriminantFunctionClassificationModel.Scale(model, ProblemDataParameter.ActualValue);
    81       }
     79      if (ApplyLinearScaling.Value) SymbolicDiscriminantFunctionClassificationModel.Scale(model, ProblemDataParameter.ActualValue);
     80
     81      SymbolicDiscriminantFunctionClassificationModel.SetAccuracyMaximizingThresholds(model, ProblemDataParameter.ActualValue);
    8282      return new SymbolicDiscriminantFunctionClassificationSolution(model, (IClassificationProblemData)ProblemDataParameter.ActualValue.Clone());
    8383    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/MultiObjective/SymbolicClassificationMultiObjectiveValidationBestSolutionAnalyzer.cs

    r7259 r8531  
    6666    protected override ISymbolicClassificationSolution CreateSolution(ISymbolicExpressionTree bestTree, double[] bestQualities) {
    6767      var model = new SymbolicDiscriminantFunctionClassificationModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper);
    68       if (ApplyLinearScaling.Value) {
    69         SymbolicDiscriminantFunctionClassificationModel.Scale(model, ProblemDataParameter.ActualValue);
    70       }
     68      if (ApplyLinearScaling.Value) SymbolicDiscriminantFunctionClassificationModel.Scale(model, ProblemDataParameter.ActualValue);
     69
     70      SymbolicDiscriminantFunctionClassificationModel.SetAccuracyMaximizingThresholds(model, ProblemDataParameter.ActualValue);
    7171      return new SymbolicDiscriminantFunctionClassificationSolution(model, (IClassificationProblemData)ProblemDataParameter.ActualValue.Clone());
    7272    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectiveTrainingBestSolutionAnalyzer.cs

    r7259 r8531  
    7575    protected override ISymbolicClassificationSolution CreateSolution(ISymbolicExpressionTree bestTree, double bestQuality) {
    7676      var model = new SymbolicDiscriminantFunctionClassificationModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper);
    77       if (ApplyLinearScaling.Value) {
    78         SymbolicDiscriminantFunctionClassificationModel.Scale(model, ProblemDataParameter.ActualValue);
    79       }
     77      if (ApplyLinearScaling.Value) SymbolicDiscriminantFunctionClassificationModel.Scale(model, ProblemDataParameter.ActualValue);
     78
     79      SymbolicDiscriminantFunctionClassificationModel.SetAccuracyMaximizingThresholds(model, ProblemDataParameter.ActualValue);
    8080      return new SymbolicDiscriminantFunctionClassificationSolution(model, (IClassificationProblemData)ProblemDataParameter.ActualValue.Clone());
    8181    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectiveTrainingParetoBestSolutionAnalyzer.cs

    r8169 r8531  
    6060    protected override ISymbolicClassificationSolution CreateSolution(ISymbolicExpressionTree bestTree) {
    6161      var model = new SymbolicDiscriminantFunctionClassificationModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper);
    62       if (ApplyLinearScaling.Value)
    63         SymbolicDiscriminantFunctionClassificationModel.Scale(model, ProblemDataParameter.ActualValue);
     62      if (ApplyLinearScaling.Value) SymbolicDiscriminantFunctionClassificationModel.Scale(model, ProblemDataParameter.ActualValue);
     63
     64      SymbolicDiscriminantFunctionClassificationModel.SetAccuracyMaximizingThresholds(model, ProblemDataParameter.ActualValue);
    6465      return new SymbolicDiscriminantFunctionClassificationSolution(model, (IClassificationProblemData)ProblemDataParameter.ActualValue.Clone());
    6566    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectiveValidationBestSolutionAnalyzer.cs

    r7259 r8531  
    6666    protected override ISymbolicClassificationSolution CreateSolution(ISymbolicExpressionTree bestTree, double bestQuality) {
    6767      var model = new SymbolicDiscriminantFunctionClassificationModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper);
    68       if (ApplyLinearScaling.Value) {
    69         SymbolicDiscriminantFunctionClassificationModel.Scale(model, ProblemDataParameter.ActualValue);
    70       }
     68      if (ApplyLinearScaling.Value) SymbolicDiscriminantFunctionClassificationModel.Scale(model, ProblemDataParameter.ActualValue);
     69
     70      SymbolicDiscriminantFunctionClassificationModel.SetAccuracyMaximizingThresholds(model, ProblemDataParameter.ActualValue);
    7171      return new SymbolicDiscriminantFunctionClassificationSolution(model, (IClassificationProblemData)ProblemDataParameter.ActualValue.Clone());
    7272    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectiveValidationParetoBestSolutionAnalyzer.cs

    r8169 r8531  
    6060    protected override ISymbolicClassificationSolution CreateSolution(ISymbolicExpressionTree bestTree) {
    6161      var model = new SymbolicDiscriminantFunctionClassificationModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper);
    62       if (ApplyLinearScaling.Value)
    63         SymbolicDiscriminantFunctionClassificationModel.Scale(model, ProblemDataParameter.ActualValue);
     62      if (ApplyLinearScaling.Value) SymbolicDiscriminantFunctionClassificationModel.Scale(model, ProblemDataParameter.ActualValue);
     63
     64      SymbolicDiscriminantFunctionClassificationModel.SetAccuracyMaximizingThresholds(model, ProblemDataParameter.ActualValue);
    6465      return new SymbolicDiscriminantFunctionClassificationSolution(model, (IClassificationProblemData)ProblemDataParameter.ActualValue.Clone());
    6566    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicDiscriminantFunctionClassificationModel.cs

    r8528 r8531  
    6767      double lowerEstimationLimit = double.MinValue, double upperEstimationLimit = double.MaxValue)
    6868      : base(tree, interpreter) {
    69       thresholds = new double[] { double.NegativeInfinity };
    70       classValues = new double[] { 0.0 };
     69      this.thresholds = new double[0];
     70      this.classValues = new double[0];
    7171      this.lowerEstimationLimit = lowerEstimationLimit;
    7272      this.upperEstimationLimit = upperEstimationLimit;
     
    8888
    8989    public IEnumerable<double> GetEstimatedValues(Dataset dataset, IEnumerable<int> rows) {
    90       return Interpreter.GetSymbolicExpressionTreeValues(SymbolicExpressionTree, dataset, rows)
    91         .LimitToRange(lowerEstimationLimit, upperEstimationLimit);
     90      return Interpreter.GetSymbolicExpressionTreeValues(SymbolicExpressionTree, dataset, rows).LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    9291    }
    9392
    9493    public IEnumerable<double> GetEstimatedClassValues(Dataset dataset, IEnumerable<int> rows) {
     94      if (!Thresholds.Any() && !ClassValues.Any()) throw new ArgumentException("No thresholds and class values were set for the current symbolic classification model.");
    9595      foreach (var x in GetEstimatedValues(dataset, rows)) {
    9696        int classIndex = 0;
     
    121121    }
    122122    #endregion
     123
     124    public static void SetAccuracyMaximizingThresholds(IDiscriminantFunctionClassificationModel model, IClassificationProblemData problemData) {
     125      double[] classValues;
     126      double[] thresholds;
     127      var targetClassValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TrainingIndices);
     128      var estimatedTrainingValues = model.GetEstimatedValues(problemData.Dataset, problemData.TrainingIndices);
     129      AccuracyMaximizationThresholdCalculator.CalculateThresholds(problemData, estimatedTrainingValues, targetClassValues, out classValues, out thresholds);
     130
     131      model.SetThresholdsAndClassValues(thresholds, classValues);
     132    }
     133
     134    public static void SetClassDistibutionCutPointThresholds(IDiscriminantFunctionClassificationModel model, IClassificationProblemData problemData) {
     135      double[] classValues;
     136      double[] thresholds;
     137      var targetClassValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TrainingIndices);
     138      var estimatedTrainingValues = model.GetEstimatedValues(problemData.Dataset, problemData.TrainingIndices);
     139      NormalDistributionCutPointsThresholdCalculator.CalculateThresholds(problemData, estimatedTrainingValues, targetClassValues, out classValues, out thresholds);
     140
     141      model.SetThresholdsAndClassValues(thresholds, classValues);
     142    }
    123143
    124144    public static void Scale(SymbolicDiscriminantFunctionClassificationModel model, IClassificationProblemData problemData) {
Note: See TracChangeset for help on using the changeset viewer.