Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/12/11 19:24:45 (12 years ago)
Author:
gkronber
Message:

#1656 implemented calculator to calculate the normalized Gini coefficient for classification solutions.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj

    r6866 r6913  
    147147    <Compile Include="Interfaces\TimeSeriesPrognosis\ITimeSeriesPrognosisProblemData.cs" />
    148148    <Compile Include="Interfaces\TimeSeriesPrognosis\ITimeSeriesPrognosisSolution.cs" />
     149    <Compile Include="OnlineCalculators\NormalizedGiniCalculator.cs" />
    149150    <Compile Include="OnlineCalculators\OnlineDirectionalSymmetryCalculator.cs" />
    150151    <Compile Include="OnlineCalculators\OnlineMeanAbsoluteErrorCalculator.cs" />
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolutionBase.cs

    r6740 r6913  
    3232    private const string TrainingAccuracyResultName = "Accuracy (training)";
    3333    private const string TestAccuracyResultName = "Accuracy (test)";
     34    private const string TrainingNormalizedGiniCoefficientResultName = "Normalized Gini Coefficient (training)";
     35    private const string TestNormalizedGiniCoefficientResultName = "Normalized Gini Coefficient (test)";
    3436
    3537    public new IClassificationModel Model {
     
    5254      private set { ((DoubleValue)this[TestAccuracyResultName].Value).Value = value; }
    5355    }
     56    public double TrainingNormalizedGiniCoefficient {
     57      get { return ((DoubleValue)this[TrainingNormalizedGiniCoefficientResultName].Value).Value; }
     58      protected set { ((DoubleValue)this[TrainingNormalizedGiniCoefficientResultName].Value).Value = value; }
     59    }
     60    public double TestNormalizedGiniCoefficient {
     61      get { return ((DoubleValue)this[TestNormalizedGiniCoefficientResultName].Value).Value; }
     62      protected set { ((DoubleValue)this[TestNormalizedGiniCoefficientResultName].Value).Value = value; }
     63    }
    5464    #endregion
    5565
     
    6373      Add(new Result(TrainingAccuracyResultName, "Accuracy of the model on the training partition (percentage of correctly classified instances).", new PercentValue()));
    6474      Add(new Result(TestAccuracyResultName, "Accuracy of the model on the test partition (percentage of correctly classified instances).", new PercentValue()));
     75      Add(new Result(TrainingNormalizedGiniCoefficientResultName, "Normalized Gini coefficient of the model on the training partition.", new DoubleValue()));
     76      Add(new Result(TestNormalizedGiniCoefficientResultName, "Normalized Gini coefficient of the model on the test partition.", new DoubleValue()));
    6577    }
    6678
     
    7991      TrainingAccuracy = trainingAccuracy;
    8092      TestAccuracy = testAccuracy;
     93
     94      double trainingNormalizedGini = NormalizedGiniCalculator.Calculate(originalTrainingClassValues, estimatedTrainingClassValues, out errorState);
     95      if (errorState != OnlineCalculatorError.None) trainingNormalizedGini = double.NaN;
     96      double testNormalizedGini = NormalizedGiniCalculator.Calculate(originalTestClassValues, estimatedTestClassValues, out errorState);
     97      if (errorState != OnlineCalculatorError.None) testNormalizedGini = double.NaN;
     98
     99      TrainingNormalizedGiniCoefficient = trainingNormalizedGini;
     100      TestNormalizedGiniCoefficient = testNormalizedGini;
    81101    }
    82102
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolutionBase.cs

    r6740 r6913  
    117117      double testR2 = OnlinePearsonsRSquaredCalculator.Calculate(estimatedTestValues, originalTestValues, out errorState);
    118118      TestRSquared = errorState == OnlineCalculatorError.None ? testR2 : double.NaN;
     119
     120      double trainingNormalizedGini = NormalizedGiniCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
     121      if (errorState != OnlineCalculatorError.None) trainingNormalizedGini = double.NaN;
     122      double testNormalizedGini = NormalizedGiniCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
     123      if (errorState != OnlineCalculatorError.None) testNormalizedGini = double.NaN;
     124
     125      TrainingNormalizedGiniCoefficient = trainingNormalizedGini;
     126      TestNormalizedGiniCoefficient = testNormalizedGini;
    119127    }
    120128
Note: See TracChangeset for help on using the changeset viewer.