Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/29/11 20:05:38 (13 years ago)
Author:
gkronber
Message:

#1081 worked on multi-variate time series prognosis

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionPrognosedValuesView.cs

    r6802 r7100  
    2020#endregion
    2121using System;
     22using System.Collections.Generic;
    2223using System.Linq;
    2324using System.Windows.Forms;
     
    3233  public partial class TimeSeriesPrognosisSolutionEstimatedValuesView : DataAnalysisSolutionEvaluationView {
    3334    private const string TARGETVARIABLE_SERIES_NAME = "Target Variable";
    34     private const string PROGNOSEDVALUES_SERIES_NAME = "Prognosed Values (all)";
    3535    private const string PROGNOSEDVALUES_TRAINING_SERIES_NAME = "Prognosed Values (training)";
    3636    private const string PROGNOSEDVALUES_TEST_SERIES_NAME = "Prognosed Values (test)";
     
    8585      else {
    8686        StringMatrix matrix = null;
     87        List<string> columnNames = new List<string>();
    8788        if (Content != null) {
    88           string[,] values = new string[Content.ProblemData.Dataset.Rows, 7];
     89          columnNames.Add("Id");
    8990
    90           double[] target = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray();
    91           var prognosed = Content.PrognosedValues.GetEnumerator();
    92           var prognosed_training = Content.PrognosedTrainingValues.GetEnumerator();
    93           var prognosed_test = Content.PrognosedTestValues.GetEnumerator();
     91          string[,] values = new string[Content.ProblemData.Dataset.Rows, 1 + 3 * Content.ProblemData.TargetVariables.Count()];
     92          foreach (var row in Enumerable.Range(0, Content.ProblemData.Dataset.Rows))
     93            values[row, 0] = row.ToString();
    9494
    95           foreach (var row in Content.ProblemData.TrainingIndizes) {
    96             prognosed_training.MoveNext();
    97             values[row, 3] = prognosed_training.Current.ToString();
    98           }
     95          var prognosedTraining = Content.PrognosedTrainingValues.ToArray();
     96          var prognosedTest = Content.PrognosedTestValues.ToArray();
    9997
    100           foreach (var row in Content.ProblemData.TestIndizes) {
    101             prognosed_test.MoveNext();
    102             values[row, 4] = prognosed_test.Current.ToString();
    103           }
     98          int i = 0;
     99          int targetVariableIndex = 0;
     100          foreach (var targetVariable in Content.ProblemData.TargetVariables) {
     101            double[] target = Content.ProblemData.Dataset.GetDoubleValues(targetVariable).ToArray();
    104102
    105           foreach (var row in Enumerable.Range(0, Content.ProblemData.Dataset.Rows)) {
    106             prognosed.MoveNext();
    107             double est = prognosed.Current;
    108             double res = Math.Abs(est - target[row]);
    109             values[row, 0] = row.ToString();
    110             values[row, 1] = target[row].ToString();
    111             values[row, 2] = est.ToString();
    112             values[row, 5] = Math.Abs(res).ToString();
    113             values[row, 6] = Math.Abs(res / est).ToString();
    114           }
     103            var prognosedTrainingEnumerator = prognosedTraining[targetVariableIndex].GetEnumerator();
     104            foreach (var row in Content.ProblemData.TrainingIndizes) {
     105              prognosedTrainingEnumerator.MoveNext();
     106              values[row, i + 2] = prognosedTrainingEnumerator.Current.ToString();
     107            }
     108
     109            var prognosedTestEnumerator = prognosedTest[targetVariableIndex].GetEnumerator();
     110            foreach (var row in Content.ProblemData.TestIndizes) {
     111              prognosedTestEnumerator.MoveNext();
     112              values[row, i + 3] = prognosedTestEnumerator.Current.ToString();
     113            }
     114
     115            foreach (var row in Enumerable.Range(0, Content.ProblemData.Dataset.Rows)) {
     116              values[row, i + 1] = target[row].ToString();
     117            }
     118
     119            columnNames.AddRange(new string[] { targetVariable + "(actual)", targetVariable + "(training)", targetVariable + "(test)" });
     120            i += 3;
     121            targetVariableIndex++;
     122          } // foreach
     123
    115124
    116125          matrix = new StringMatrix(values);
    117           matrix.ColumnNames = new string[] { "Id", TARGETVARIABLE_SERIES_NAME, PROGNOSEDVALUES_SERIES_NAME, PROGNOSEDVALUES_TRAINING_SERIES_NAME, PROGNOSEDVALUES_TEST_SERIES_NAME, "Absolute Error (all)", "Relative Error (all)" };
     126          matrix.ColumnNames = columnNames.ToArray();
    118127          matrix.SortableView = true;
    119         }
     128
     129        } // if
    120130        matrixView.Content = matrix;
    121131      }
Note: See TracChangeset for help on using the changeset viewer.