1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 | using System;
|
---|
22 | using System.Linq;
|
---|
23 | using System.Windows.Forms;
|
---|
24 | using HeuristicLab.Data;
|
---|
25 | using HeuristicLab.MainForm;
|
---|
26 | using HeuristicLab.MainForm.WindowsForms;
|
---|
27 |
|
---|
28 | namespace HeuristicLab.Problems.DataAnalysis.Views {
|
---|
29 | [View("Estimated Class Values")]
|
---|
30 | [Content(typeof(IDiscriminantFunctionClassificationSolution))]
|
---|
31 | public partial class DiscriminantFunctionClassificationSolutionEstimatedClassValuesView : ClassificationSolutionEstimatedClassValuesView {
|
---|
32 | private const string TARGETVARIABLE_SERIES_NAME = "TargetVariable";
|
---|
33 | private const string ESTIMATEDVALUES_SERIES_NAME = "Estimated Class Values (all)";
|
---|
34 | private const string ESTIMATEDVALUES_TRAINING_SERIES_NAME = "Estimated Class Values (training)";
|
---|
35 | private const string ESTIMATEDVALUES_TEST_SERIES_NAME = "Estimated Class Values (test)";
|
---|
36 | private const string ESTIMATEDVALUES_DISCRIMINANT_SERIES_NAME = "Discriminant Values (all)";
|
---|
37 |
|
---|
38 | public new IDiscriminantFunctionClassificationSolution Content {
|
---|
39 | get { return (IDiscriminantFunctionClassificationSolution)base.Content; }
|
---|
40 | set { base.Content = value; }
|
---|
41 | }
|
---|
42 |
|
---|
43 | public DiscriminantFunctionClassificationSolutionEstimatedClassValuesView()
|
---|
44 | : base() {
|
---|
45 | InitializeComponent();
|
---|
46 | }
|
---|
47 |
|
---|
48 | protected override void UpdateEstimatedValues() {
|
---|
49 | if (InvokeRequired) Invoke((Action)UpdateEstimatedValues);
|
---|
50 | else {
|
---|
51 | StringMatrix matrix = null;
|
---|
52 | if (Content != null) {
|
---|
53 | string[,] values = new string[Content.ProblemData.Dataset.Rows, 6];
|
---|
54 | double[] target = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray();
|
---|
55 | double[] estimatedClassValue = Content.EstimatedClassValues.ToArray();
|
---|
56 | double[] estimatedValues = Content.EstimatedValues.ToArray();
|
---|
57 | for (int row = 0; row < target.Length; row++) {
|
---|
58 | values[row, 0] = row.ToString();
|
---|
59 | values[row, 1] = target[row].ToString();
|
---|
60 | values[row, 2] = estimatedClassValue[row].ToString();
|
---|
61 | values[row, 5] = estimatedValues[row].ToString();
|
---|
62 | }
|
---|
63 |
|
---|
64 | var estimatedTraining = Content.EstimatedTrainingClassValues.GetEnumerator();
|
---|
65 | estimatedTraining.MoveNext();
|
---|
66 | foreach (var trainingRow in Content.ProblemData.TrainingIndices) {
|
---|
67 | values[trainingRow, 3] = estimatedTraining.Current.ToString();
|
---|
68 | estimatedTraining.MoveNext();
|
---|
69 | }
|
---|
70 | var estimatedTest = Content.EstimatedTestClassValues.GetEnumerator();
|
---|
71 | estimatedTest.MoveNext();
|
---|
72 | foreach (var testRow in Content.ProblemData.TestIndices) {
|
---|
73 | values[testRow, 4] = estimatedTest.Current.ToString();
|
---|
74 | estimatedTest.MoveNext();
|
---|
75 | }
|
---|
76 |
|
---|
77 | matrix = new StringMatrix(values);
|
---|
78 | matrix.ColumnNames = new string[] { "Id", TARGETVARIABLE_SERIES_NAME, ESTIMATEDVALUES_SERIES_NAME, ESTIMATEDVALUES_TRAINING_SERIES_NAME, ESTIMATEDVALUES_TEST_SERIES_NAME, ESTIMATEDVALUES_DISCRIMINANT_SERIES_NAME };
|
---|
79 | matrix.SortableView = true;
|
---|
80 | }
|
---|
81 | matrixView.Content = matrix;
|
---|
82 | }
|
---|
83 | }
|
---|
84 | }
|
---|
85 | }
|
---|