Free cookie consent management tool by TermsFeed Policy Generator

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

#1450: implemented support for ensemble solutions for classification.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.