Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/06/14 14:14:42 (10 years ago)
Author:
gkronber
Message:

#2197: fixed bugs in views for data analysis solutions that might occur if the problem does not have training samples (e.g. when the data is loaded into an existing solution)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionErrorCharacteristicsCurveView.cs

    r9462 r11093  
    2222using System.Collections.Generic;
    2323using System.Linq;
    24 using System.Windows.Forms;
    2524using HeuristicLab.MainForm;
    26 using HeuristicLab.MainForm.WindowsForms;
     25
    2726namespace HeuristicLab.Problems.DataAnalysis.Views {
    2827  [View("Error Characteristics Curve")]
     
    5150      if (Content == null) return;
    5251
    53       //AR1 model
    54       double alpha, beta;
    55       OnlineCalculatorError errorState;
    5652      IEnumerable<double> trainingStartValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices.Select(r => r - 1).Where(r => r > 0)).ToList();
    57       OnlineLinearScalingParameterCalculator.Calculate(ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices.Where(x => x > 0)), trainingStartValues, out alpha, out beta, out errorState);
    58       var AR1model = new TimeSeriesPrognosisAutoRegressiveModel(ProblemData.TargetVariable, new double[] { beta }, alpha).CreateTimeSeriesPrognosisSolution(ProblemData);
    59       AR1model.Name = "AR(1) Model";
    60       AddRegressionSolution(AR1model);
     53      if (trainingStartValues.Any()) {
     54        //AR1 model
     55        double alpha, beta;
     56        OnlineCalculatorError errorState;
     57        OnlineLinearScalingParameterCalculator.Calculate(ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices.Where(x => x > 0)), trainingStartValues, out alpha, out beta, out errorState);
     58        var ar1model = new TimeSeriesPrognosisAutoRegressiveModel(ProblemData.TargetVariable, new double[] { beta }, alpha).CreateTimeSeriesPrognosisSolution(ProblemData);
     59        ar1model.Name = "AR(1) Model";
     60        AddRegressionSolution(ar1model);
     61      }
    6162    }
    6263  }
Note: See TracChangeset for help on using the changeset viewer.