Changeset 14029 for branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis
- Timestamp:
- 07/08/16 14:40:02 (8 years ago)
- Location:
- branches/crossvalidation-2434
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/crossvalidation-2434
- Property svn:mergeinfo changed
-
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
-
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/Models/ConstantTimeSeriesPrognosisModel.cs
r12509 r14029 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 29 30 [StorableClass] 30 31 [Item("Constant TimeSeries Model", "A time series model that returns for all prediciton the same constant value.")] 32 [Obsolete] 31 33 public class ConstantTimeSeriesPrognosisModel : ConstantRegressionModel, ITimeSeriesPrognosisModel { 32 34 [StorableConstructor] … … 37 39 } 38 40 39 public ConstantTimeSeriesPrognosisModel(double constant ) : base(constant) { }41 public ConstantTimeSeriesPrognosisModel(double constant, string targetVariable) : base(constant, targetVariable) { } 40 42 41 43 public IEnumerable<IEnumerable<double>> GetPrognosedValues(IDataset dataset, IEnumerable<int> rows, IEnumerable<int> horizons) { -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/Models/TimeSeriesPrognosisAutoRegressiveModel.cs
r12509 r14029 30 30 [StorableClass] 31 31 [Item("Autoregressive TimeSeries Model", "A linear autoregressive time series model used to predict future values.")] 32 public class TimeSeriesPrognosisAutoRegressiveModel : NamedItem, ITimeSeriesPrognosisModel { 32 public class TimeSeriesPrognosisAutoRegressiveModel : RegressionModel, ITimeSeriesPrognosisModel { 33 public override IEnumerable<string> VariablesUsedForPrediction { 34 get { return new[] { TargetVariable }; } 35 } 36 33 37 [Storable] 34 38 public double[] Phi { get; private set; } 35 39 [Storable] 36 40 public double Constant { get; private set; } 37 [Storable]38 public string TargetVariable { get; private set; }39 41 40 42 public int TimeOffset { get { return Phi.Length; } } … … 46 48 this.Phi = (double[])original.Phi.Clone(); 47 49 this.Constant = original.Constant; 48 this.TargetVariable = original.TargetVariable;49 50 } 50 51 public override IDeepCloneable Clone(Cloner cloner) { … … 52 53 } 53 54 public TimeSeriesPrognosisAutoRegressiveModel(string targetVariable, double[] phi, double constant) 54 : base( "AR(1) Model") {55 : base(targetVariable, "AR(1) Model") { 55 56 Phi = (double[])phi.Clone(); 56 57 Constant = constant; 57 TargetVariable = targetVariable;58 58 } 59 59 … … 91 91 } 92 92 93 public IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) {93 public override IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) { 94 94 var targetVariables = dataset.GetReadOnlyDoubleValues(TargetVariable); 95 95 foreach (int row in rows) { … … 111 111 return new TimeSeriesPrognosisSolution(this, new TimeSeriesPrognosisProblemData(problemData)); 112 112 } 113 public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {113 public override IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) { 114 114 throw new NotSupportedException(); 115 115 } -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisResults.cs
r12641 r14029 373 373 //mean model 374 374 double trainingMean = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TrainingIndices).Average(); 375 var meanModel = new Constant TimeSeriesPrognosisModel(trainingMean);375 var meanModel = new ConstantModel(trainingMean, problemData.TargetVariable); 376 376 377 377 //AR1 model … … 395 395 PrognosisTrainingMeanAbsoluteError = errorState == OnlineCalculatorError.None ? trainingMAE : double.NaN; 396 396 double trainingR = OnlinePearsonsRCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState); 397 PrognosisTrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR *trainingR : double.NaN;397 PrognosisTrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR * trainingR : double.NaN; 398 398 double trainingRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState); 399 399 PrognosisTrainingRelativeError = errorState == OnlineCalculatorError.None ? trainingRelError : double.NaN; … … 431 431 PrognosisTestMeanAbsoluteError = errorState == OnlineCalculatorError.None ? testMAE : double.NaN; 432 432 double testR = OnlinePearsonsRCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState); 433 PrognosisTestRSquared = errorState == OnlineCalculatorError.None ? testR *testR : double.NaN;433 PrognosisTestRSquared = errorState == OnlineCalculatorError.None ? testR * testR : double.NaN; 434 434 double testRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState); 435 435 PrognosisTestRelativeError = errorState == OnlineCalculatorError.None ? testRelError : double.NaN; … … 448 448 //mean model 449 449 double trainingMean = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TrainingIndices).Average(); 450 var meanModel = new Constant TimeSeriesPrognosisModel(trainingMean);450 var meanModel = new ConstantModel(trainingMean, problemData.TargetVariable); 451 451 452 452 //AR1 model -
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionBase.cs
r12012 r14029 150 150 OnlineCalculatorError errorState; 151 151 double trainingMean = ProblemData.TrainingIndices.Any() ? ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).Average() : double.NaN; 152 var meanModel = new Constant TimeSeriesPrognosisModel(trainingMean);152 var meanModel = new ConstantModel(trainingMean,ProblemData.TargetVariable); 153 153 154 154 double alpha, beta;
Note: See TracChangeset
for help on using the changeset viewer.