Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/20/11 16:10:07 (13 years ago)
Author:
gkronber
Message:

#1450: implemented support for ensemble solutions for classification.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionConfusionMatrixView.cs

    r5975 r6239  
    103103        IEnumerable<int> rows;
    104104
     105        double[] predictedValues;
    105106        if (cmbSamples.SelectedItem.ToString() == TrainingSamples) {
    106107          rows = Content.ProblemData.TrainingIndizes;
     108          predictedValues = Content.EstimatedTrainingClassValues.ToArray();
    107109        } else if (cmbSamples.SelectedItem.ToString() == TestSamples) {
    108110          rows = Content.ProblemData.TestIndizes;
     111          predictedValues = Content.EstimatedTestClassValues.ToArray();         
    109112        } else throw new InvalidOperationException();
     113
     114        double[] targetValues = Content.ProblemData.Dataset.GetEnumeratedVariableValues(Content.ProblemData.TargetVariable, rows).ToArray();
    110115
    111116        Dictionary<double, int> classValueIndexMapping = new Dictionary<double, int>();
     
    115120          index++;
    116121        }
    117 
    118         double[] targetValues = Content.ProblemData.Dataset.GetEnumeratedVariableValues(Content.ProblemData.TargetVariable, rows).ToArray();
    119         double[] predictedValues = Content.GetEstimatedClassValues(rows).ToArray();
    120122
    121123        for (int i = 0; i < targetValues.Length; i++) {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionEstimatedClassValuesView.cs

    r5975 r6239  
    3232  [Content(typeof(IClassificationSolution))]
    3333  public partial class ClassificationSolutionEstimatedClassValuesView : ItemView, IClassificationSolutionEvaluationView {
    34     private const string TARGETVARIABLE_SERIES_NAME = "TargetVariable";
    35     private const string ESTIMATEDVALUES_SERIES_NAME = "EstimatedClassValues";
     34    private const string TARGETVARIABLE_SERIES_NAME = "Target Variable";
     35    private const string ESTIMATEDVALUES_TRAINING_SERIES_NAME = "Estimated Class Values (training)";
     36    private const string ESTIMATEDVALUES_TEST_SERIES_NAME = "Estimated Class Values (test)";
    3637
    3738    public new IClassificationSolution Content {
     
    8586        DoubleMatrix matrix = null;
    8687        if (Content != null) {
    87           double[,] values = new double[Content.ProblemData.Dataset.Rows, 2];
     88          double[,] values = new double[Content.ProblemData.Dataset.Rows, 3];
     89          // fill with NaN
     90          for (int row = 0; row < Content.ProblemData.Dataset.Rows; row++)
     91            for (int column = 0; column < 3; column++)
     92              values[row, column] = double.NaN;
    8893
    8994          double[] target = Content.ProblemData.Dataset.GetVariableValues(Content.ProblemData.TargetVariable);
    90           double[] estimated = Content.EstimatedClassValues.ToArray();
    9195          for (int row = 0; row < target.Length; row++) {
    9296            values[row, 0] = target[row];
    93             values[row, 1] = estimated[row];
     97          }
     98          var estimatedTraining = Content.EstimatedTrainingClassValues.GetEnumerator();
     99          estimatedTraining.MoveNext();
     100          foreach (var trainingRow in Content.ProblemData.TrainingIndizes) {
     101            values[trainingRow, 1] = estimatedTraining.Current;
     102            estimatedTraining.MoveNext();
     103          }
     104          var estimatedTest = Content.EstimatedTestClassValues.GetEnumerator();
     105          estimatedTest.MoveNext();
     106          foreach (var testRow in Content.ProblemData.TestIndizes) {
     107            values[testRow, 2] = estimatedTest.Current;
     108            estimatedTest.MoveNext();
    94109          }
    95110
    96111          matrix = new DoubleMatrix(values);
    97           matrix.ColumnNames = new string[] { TARGETVARIABLE_SERIES_NAME, ESTIMATEDVALUES_SERIES_NAME };
     112          matrix.ColumnNames = new string[] { TARGETVARIABLE_SERIES_NAME, ESTIMATEDVALUES_TRAINING_SERIES_NAME, ESTIMATEDVALUES_TEST_SERIES_NAME };
    98113        }
    99114        matrixView.Content = matrix;
Note: See TracChangeset for help on using the changeset viewer.