Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14422


Ignore:
Timestamp:
11/26/16 23:21:50 (8 years ago)
Author:
gkronber
Message:

#2529: added a way to calculate prognosed values for the whole test partition and added a specific implementation of the line chart for time series models

Location:
trunk/sources
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj

    r14348 r14422  
    409409    <Compile Include="Solution Views\TimeSeriesPrognosisSolutionView.Designer.cs">
    410410      <DependentUpon>TimeSeriesPrognosisSolutionView.cs</DependentUpon>
     411    </Compile>
     412    <Compile Include="TimeSeriesPrognosis\TimeSeriesPrognosisLineChartView.cs">
     413      <SubType>UserControl</SubType>
     414    </Compile>
     415    <Compile Include="TimeSeriesPrognosis\TimeSeriesPrognosisLineChartView.Designer.cs">
     416      <DependentUpon>TimeSeriesPrognosisLineChartView.cs</DependentUpon>
    411417    </Compile>
    412418    <Compile Include="TimeSeriesPrognosis\TimeSeriesPrognosisResultsView.cs">
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartView.cs

    r14255 r14422  
    5757    }
    5858
     59    protected virtual void GetTrainingSeries(out int[] x, out double[] y) {
     60      x = Content.ProblemData.TrainingIndices.ToArray();
     61      y = Content.EstimatedTrainingValues.ToArray();
     62    }
     63
     64    protected virtual void GetTestSeries(out int[] x, out double[] y) {
     65      x = Content.ProblemData.TestIndices.ToArray();
     66      y = Content.EstimatedTestValues.ToArray();
     67    }
     68
     69    protected virtual void GetAllValuesSeries(out int[] x, out double[] y) {
     70      x = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).Except(Content.ProblemData.TrainingIndices).Except(Content.ProblemData.TestIndices).ToArray();
     71      var tmp = Content.EstimatedValues.ToArray();
     72      y = x.Select(index => tmp[index]).ToArray();
     73    }
     74
    5975    private void RedrawChart() {
    6076      this.chart.Series.Clear();
     
    7389        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].ChartType = SeriesChartType.FastLine;
    7490        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].EmptyPointStyle.Color = this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Color;
    75         this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TrainingIndices.ToArray(), Content.EstimatedTrainingValues.ToArray());
     91        int[] trainingIdx;
     92        double[] trainingY;
     93        GetTrainingSeries(out trainingIdx, out trainingY);
     94        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Points.DataBindXY(trainingIdx, trainingY);
    7695        this.InsertEmptyPoints(this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME]);
    7796        this.chart.Series[ESTIMATEDVALUES_TRAINING_SERIES_NAME].Tag = Content;
     97
    7898        // test series
    7999        this.chart.Series.Add(ESTIMATEDVALUES_TEST_SERIES_NAME);
    80100        this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].LegendText = ESTIMATEDVALUES_TEST_SERIES_NAME;
    81101        this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].ChartType = SeriesChartType.FastLine;
    82         this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Points.DataBindXY(Content.ProblemData.TestIndices.ToArray(), Content.EstimatedTestValues.ToArray());
     102        int[] testIdx;
     103        double[] testY;
     104        GetTestSeries(out testIdx, out testY);
     105        this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Points.DataBindXY(testIdx, testY);
    83106        this.InsertEmptyPoints(this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME]);
    84107        this.chart.Series[ESTIMATEDVALUES_TEST_SERIES_NAME].Tag = Content;
     108
    85109        // series of remaining points
    86         int[] allIndices = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).Except(Content.ProblemData.TrainingIndices).Except(Content.ProblemData.TestIndices).ToArray();
    87         var estimatedValues = Content.EstimatedValues.ToArray();
    88         List<double> allEstimatedValues = allIndices.Select(index => estimatedValues[index]).ToList();
     110        int[] allIdx;
     111        double[] allEstimatedValues;
     112        GetAllValuesSeries(out allIdx, out allEstimatedValues);
     113
    89114        this.chart.Series.Add(ESTIMATEDVALUES_ALL_SERIES_NAME);
    90115        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].LegendText = ESTIMATEDVALUES_ALL_SERIES_NAME;
    91116        this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].ChartType = SeriesChartType.FastLine;
    92         if (allEstimatedValues.Count > 0) {
    93           this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Points.DataBindXY(allIndices, allEstimatedValues);
     117        if (allEstimatedValues.Length > 0) {
     118          this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME].Points.DataBindXY(allIdx, allEstimatedValues);
    94119          this.InsertEmptyPoints(this.chart.Series[ESTIMATEDVALUES_ALL_SERIES_NAME]);
    95120        }
     
    244269        }
    245270      } else if (Content != null) {
    246         string targetVariableName = Content.ProblemData.TargetVariable;
    247 
    248         IEnumerable<int> indices = null;
     271
     272        int[] indices = null;
    249273        double[] predictedValues = null;
    250274        switch (series.Name) {
    251275          case ESTIMATEDVALUES_ALL_SERIES_NAME:
    252             indices = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).Except(Content.ProblemData.TrainingIndices).Except(Content.ProblemData.TestIndices).ToArray();
    253             var estimatedValues = Content.EstimatedValues.ToArray();
    254             predictedValues = indices.Select(index => estimatedValues[index]).ToArray();
     276            GetAllValuesSeries(out indices, out predictedValues);
    255277            break;
    256278          case ESTIMATEDVALUES_TRAINING_SERIES_NAME:
    257             indices = Content.ProblemData.TrainingIndices.ToArray();
    258             predictedValues = Content.EstimatedTrainingValues.ToArray();
     279            GetTrainingSeries(out indices, out predictedValues);
    259280            break;
    260281          case ESTIMATEDVALUES_TEST_SERIES_NAME:
    261             indices = Content.ProblemData.TestIndices.ToArray();
    262             predictedValues = Content.EstimatedTestValues.ToArray();
     282            GetTestSeries(out indices, out predictedValues);
    263283            break;
    264284        }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisSolution.cs

    r14185 r14422  
    2121
    2222using System.Collections.Generic;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    4344      return Model.GetPrognosedValues(ProblemData.Dataset, rows, horizons);
    4445    }
     46
     47    public override IEnumerable<double> PrognosedTestValues {
     48      get {
     49        return Model.GetPrognosedValues(ProblemData.Dataset, ProblemData.TestIndices.Take(1),
     50          new int[] { ProblemData.TestIndices.Count() }).First();
     51      }
     52    }
    4553  }
    4654}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionBase.cs

    r14185 r14422  
    6464    }
    6565
     66    public abstract IEnumerable<double> PrognosedTestValues { get; }
    6667    public abstract IEnumerable<IEnumerable<double>> GetPrognosedValues(IEnumerable<int> rows, IEnumerable<int> horizon);
    6768
     
    150151      OnlineCalculatorError errorState;
    151152      double trainingMean = ProblemData.TrainingIndices.Any() ? ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).Average() : double.NaN;
    152       var meanModel = new ConstantModel(trainingMean,ProblemData.TargetVariable);
     153      var meanModel = new ConstantModel(trainingMean, ProblemData.TargetVariable);
    153154
    154155      double alpha, beta;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/TimeSeriesPrognosis/ITimeSeriesPrognosisSolution.cs

    r14185 r14422  
    2828    IEnumerable<IEnumerable<double>> GetPrognosedValues(IEnumerable<int> rows, IEnumerable<int> horizon);
    2929
     30    IEnumerable<double> PrognosedTestValues { get; }
     31
    3032    double TrainingTheilsUStatisticAR1 { get; }
    3133    double TestTheilsUStatisticAR1 { get; }
Note: See TracChangeset for help on using the changeset viewer.