Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8862


Ignore:
Timestamp:
10/30/12 14:22:20 (11 years ago)
Author:
sforsten
Message:

#1776:

  • adapted the implementation of ClassificationEnsembleSolutionAccuracyToCoveredSamples to be more similar to ClassificationEnsembleSolutionAccuracyToCoveredSamples
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationEnsembleSolutionAccuracyToCoveredSamples.cs

    r8814 r8862  
    8282        var solutions = Content.ClassificationSolutions;
    8383        double[] estimatedClassValues = null;
    84         double[] classValues;
     84        double[] target;
    8585        OnlineAccuracyCalculator accuracyCalc = new OnlineAccuracyCalculator();
    8686
    87         int rows = 0;
    88         double[] confidences = null;
    89 
    90         classValues = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray();
    91 
    92         if (SamplesComboBox.SelectedItem.ToString().Equals(SamplesComboBoxAllSamples)) {
    93           rows = Content.ProblemData.Dataset.Rows;
    94           estimatedClassValues = Content.EstimatedClassValues.ToArray();
    95           confidences = weightCalc.GetConfidence(solutions,
    96                                                  Enumerable.Range(0, Content.ProblemData.Dataset.Rows),
    97                                                  estimatedClassValues,
    98                                                  weightCalc.GetAllClassDelegate()).ToArray();
    99         } else if (SamplesComboBox.SelectedItem.ToString().Equals(SamplesComboBoxTrainingSamples)) {
    100           rows = Content.ProblemData.TrainingIndices.Count();
    101           estimatedClassValues = Content.EstimatedTrainingClassValues.ToArray();
    102           confidences = weightCalc.GetConfidence(solutions,
    103                                                  Content.ProblemData.TrainingIndices,
    104                                                  estimatedClassValues,
    105                                                  weightCalc.GetTrainingClassDelegate()).ToArray();
    106         } else if (SamplesComboBox.SelectedItem.ToString().Equals(SamplesComboBoxTestSamples)) {
    107           rows = Content.ProblemData.TestIndices.Count();
    108           estimatedClassValues = Content.EstimatedTestClassValues.ToArray();
    109           confidences = weightCalc.GetConfidence(solutions,
    110                                                  Content.ProblemData.TestIndices,
    111                                                  estimatedClassValues,
    112                                                  weightCalc.GetTestClassDelegate()).ToArray();
     87        int[] indizes;
     88        double[] confidences;
     89
     90        target = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray();
     91        switch (SamplesComboBox.SelectedItem.ToString()) {
     92          case SamplesComboBoxAllSamples:
     93            indizes = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).ToArray();
     94            estimatedClassValues = Content.EstimatedClassValues.ToArray();
     95            confidences = weightCalc.GetConfidence(solutions,
     96                                                   Enumerable.Range(0, Content.ProblemData.Dataset.Rows),
     97                                                   estimatedClassValues,
     98                                                   weightCalc.GetAllClassDelegate()).ToArray();
     99            break;
     100          case SamplesComboBoxTrainingSamples:
     101            indizes = Content.ProblemData.TrainingIndices.ToArray();
     102            estimatedClassValues = Content.EstimatedTrainingClassValues.ToArray();
     103            confidences = weightCalc.GetConfidence(solutions,
     104                                                   Content.ProblemData.TrainingIndices,
     105                                                   estimatedClassValues,
     106                                                   weightCalc.GetTrainingClassDelegate()).ToArray();
     107            break;
     108          case SamplesComboBoxTestSamples:
     109            indizes = Content.ProblemData.TestIndices.ToArray();
     110            estimatedClassValues = Content.EstimatedTestClassValues.ToArray();
     111            confidences = weightCalc.GetConfidence(solutions,
     112                                                   Content.ProblemData.TestIndices,
     113                                                   estimatedClassValues,
     114                                                   weightCalc.GetTestClassDelegate()).ToArray();
     115            break;
     116          default:
     117            throw new ArgumentException();
    113118        }
    114119
     120        int row;
    115121        for (int i = 0; i < maxPoints; i++) {
    116122          double confidenceValue = (1.0 / (maxPoints - 1)) * i;
    117123          int notCovered = 0;
    118124
    119           for (int j = 0; j < rows; j++) {
     125          for (int j = 0; j < indizes.Length; j++) {
     126            row = indizes[j];
    120127            if (confidences[j] >= confidenceValue) {
    121               accuracyCalc.Add(classValues[j], estimatedClassValues[j]);
     128              accuracyCalc.Add(target[row], estimatedClassValues[j]);
    122129            } else {
    123130              notCovered++;
     
    126133
    127134          accuracy[i + 1] = accuracyCalc.Accuracy;
    128           if (rows > 0) {
    129             covered[i] = 1.0 - (double)notCovered / (double)rows;
     135          if (indizes.Length > 0) {
     136            covered[i] = 1.0 - (double)notCovered / (double)indizes.Length;
    130137          }
    131138          accuracyCalc.Reset();
Note: See TracChangeset for help on using the changeset viewer.