Changeset 7183


Ignore:
Timestamp:
12/13/11 13:52:22 (9 years ago)
Author:
gkronber
Message:

#1081 implemented remaining metrics for time series prognosis solutions, added estimation limits fixed training and validation best solution analyzers, implemented overfitting analyzer.

Location:
branches/HeuristicLab.TimeSeries
Files:
1 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis.Views-3.4.csproj

    r7154 r7183  
    5050    <DebugType>pdbonly</DebugType>
    5151    <Optimize>true</Optimize>
    52     <OutputPath>bin\Release\</OutputPath>
     52    <OutputPath>..\..\bin\</OutputPath>
    5353    <DefineConstants>TRACE</DefineConstants>
    5454    <ErrorReport>prompt</ErrorReport>
     
    110110  </ItemGroup>
    111111  <ItemGroup>
     112    <Compile Include="InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView.cs">
     113      <SubType>UserControl</SubType>
     114    </Compile>
     115    <Compile Include="InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView.Designer.cs">
     116      <DependentUpon>InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView.cs</DependentUpon>
     117    </Compile>
    112118    <Compile Include="Plugin.cs" />
    113119    <Compile Include="SymbolicTimeSeriesPrognosisSolutionView.cs">
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis.Views/3.4/InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView.cs

    r7154 r7183  
    5757    protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree) {
    5858      Dictionary<ISymbolicExpressionTreeNode, double> replacementValues = new Dictionary<ISymbolicExpressionTreeNode, double>();
    59       foreach (ISymbolicExpressionTreeNode node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix()) {
    60         replacementValues[node] = CalculateReplacementValue(node, tree);
    61       }
     59      foreach (var componentBranch in tree.Root.GetSubtree(0).Subtrees)
     60        foreach (ISymbolicExpressionTreeNode node in componentBranch.IterateNodesPrefix()) {
     61          replacementValues[node] = CalculateReplacementValue(node, tree);
     62        }
    6263      return replacementValues;
    6364    }
     
    7273        .ToArray();
    7374      int i = 0;
     75      int nTargetVariables = Content.ProblemData.TargetVariables.Count();
    7476      foreach (var targetVariable in Content.ProblemData.TargetVariables) {
    7577        List<ISymbolicExpressionTreeNode> nodes = tree.Root.GetSubtree(0).GetSubtree(i).IterateNodesPostfix().ToList();
    7678        var targetValues = dataset.GetDoubleValues(targetVariable, rows);
    7779        OnlineCalculatorError errorState;
    78         double originalR2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, originalOutput.Select(v => v.ElementAt(i)), out errorState);
     80        double originalR2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, originalOutput.Skip(i).TakeEvery(nTargetVariables), out errorState);
    7981        if (errorState != OnlineCalculatorError.None) originalR2 = 0.0;
    8082
     
    8587          SwitchNode(parent, node, replacementNode);
    8688          var newOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, Content.ProblemData.TargetVariables.ToArray(), rows, 1);
    87           double newR2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, newOutput.Select(v => v.First().ElementAt(i)), out errorState);
     89          double newR2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, newOutput.Skip(i).TakeEvery(nTargetVariables), out errorState);
    8890          if (errorState != OnlineCalculatorError.None) newR2 = 0.0;
    8991
     
    112114      var rows = Content.ProblemData.TrainingIndizes;
    113115      var allPrognosedValues = interpreter.GetSymbolicExpressionTreeValues(tempTree, Content.ProblemData.Dataset, Content.ProblemData.TargetVariables.ToArray(), rows, 1);
    114      
    115       return allPrognosedValues.Select(x=>x.First().First()).Median();
     116
     117      return allPrognosedValues.Median();
    116118    }
    117119
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis.Views/3.4/SymbolicTimeSeriesPrognosisSolutionView.cs

    r7154 r7183  
    3939
    4040    private void btn_SimplifyModel_Click(object sender, EventArgs e) {
    41       //InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView view = new InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView();
    42       //view.Content = (SymbolicTimeSeriesPrognosisSolution)this.Content.Clone();
    43       //view.Show();
     41      InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView view = new InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView();
     42      view.Content = (SymbolicTimeSeriesPrognosisSolution)this.Content.Clone();
     43      view.Show();
    4444    }
    4545  }
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis-3.4.csproj

    r7129 r7183  
    120120      <SubType>Code</SubType>
    121121    </Compile>
     122    <Compile Include="SingleObjective\SymbolicTimeSeriesPrognosisSingleObjectiveOverfittingAnalyzer.cs" />
    122123    <Compile Include="SingleObjective\SymbolicTimeSeriesPrognosisSingleObjectiveProblem.cs" />
    123124    <Compile Include="SingleObjective\SymbolicTimeSeriesPrognosisSingleObjectiveTrainingBestSolutionAnalyzer.cs" />
     125    <Compile Include="SingleObjective\SymbolicTimeSeriesPrognosisSingleObjectiveValidationBestSolutionAnalyzer.cs" />
    124126    <Compile Include="SymbolicTimeSeriesPrognosisModel.cs" />
    125127    <Compile Include="SymbolicTimeSeriesPrognosisSolution.cs" />
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SingleObjective/SymbolicTimeSeriesPrognosisSingleObjectiveMeanSquaredErrorEvaluator.cs

    r7154 r7183  
    9393        meanCalculator.Add(calc.MeanSquaredError);
    9494      }
    95       //int i = 0;
    96       //foreach (var targetVariable in problemData.TargetVariables) {
    97       //  var predictedContinuations = allPredictedContinuations.Select(v => v.ElementAt(i));
    98       //  for (int h = 0; h < horizon; h++) {
    99       //    OnlineCalculatorError errorState;
    100       //    meanCalculator.Add(OnlineMeanSquaredErrorCalculator.Calculate(predictedContinuations
    101       //                                                                    .Select(x => x.ElementAt(h))
    102       //                                                                    .LimitToRange(lowerEstimationLimit,
    103       //                                                                                  upperEstimationLimit),
    104       //                                                                  actualContinuations.Select(x => x.ElementAt(h)),
    105       //                                                                  out errorState));
    106       //    if (errorState != OnlineCalculatorError.None) return double.NaN;
    107       //  }
    108       //}
     95
    10996      return meanCalculator.MeanErrorState == OnlineCalculatorError.None ? meanCalculator.Mean : double.MaxValue;
    11097    }
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SingleObjective/SymbolicTimeSeriesPrognosisSingleObjectiveProblem.cs

    r7154 r7183  
    7676    private void InitializeOperators() {
    7777      Operators.Add(new SymbolicTimeSeriesPrognosisSingleObjectiveTrainingBestSolutionAnalyzer());
    78       //Operators.Add(new SymbolicTimeSeriesPrognosisSingleObjectiveValidationBestSolutionAnalyzer());
    79       //Operators.Add(new SymbolicTimeSeriesPrognosisSingleObjectiveOverfittingAnalyzer());
     78      Operators.Add(new SymbolicTimeSeriesPrognosisSingleObjectiveValidationBestSolutionAnalyzer());
     79      Operators.Add(new SymbolicTimeSeriesPrognosisSingleObjectiveOverfittingAnalyzer());
    8080      ParameterizeOperators();
    8181    }
    8282
    8383    private void UpdateEstimationLimits() {
    84       //if (ProblemData.TrainingIndizes.Any()) {
    85       //  var targetValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariables, ProblemData.TrainingIndizes).ToList();
    86       //  var mean = targetValues.Average();
    87       //  var range = targetValues.Max() - targetValues.Min();
    88       //  EstimationLimits.Upper = mean + PunishmentFactor * range;
    89       //  EstimationLimits.Lower = mean - PunishmentFactor * range;
    90       //} else {
    9184      EstimationLimits.Upper = double.MaxValue;
    9285      EstimationLimits.Lower = double.MinValue;
    93       //}
    9486    }
    9587
     
    10698          op.EstimationLimitsParameter.ActualName = EstimationLimitsParameter.Name;
    10799        }
    108         foreach (var op in operators.OfType<SymbolicTimeSeriesPrognosisSingleObjectiveTrainingBestSolutionAnalyzer>())
    109         {
     100        foreach (var op in operators.OfType<SymbolicTimeSeriesPrognosisSingleObjectiveTrainingBestSolutionAnalyzer>()) {
    110101          op.MaximizationParameter.ActualName = MaximizationParameter.Name;
    111102          op.ProblemDataParameter.ActualName = ProblemDataParameter.Name;
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SingleObjective/SymbolicTimeSeriesPrognosisSingleObjectiveTrainingBestSolutionAnalyzer.cs

    r7120 r7183  
    7676
    7777    protected override ISymbolicTimeSeriesPrognosisSolution CreateSolution(ISymbolicExpressionTree bestTree, double bestQuality) {
    78       var model = new SymbolicTimeSeriesPrognosisModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, ProblemDataParameter.ActualValue.TargetVariables.ToArray());
     78      var model = new SymbolicTimeSeriesPrognosisModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, ProblemDataParameter.ActualValue.TargetVariables.ToArray(), EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper);
    7979      if (ApplyLinearScaling.Value)
    8080        SymbolicTimeSeriesPrognosisModel.Scale(model, ProblemDataParameter.ActualValue);
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SingleObjective/SymbolicTimeSeriesPrognosisSingleObjectiveValidationBestSolutionAnalyzer.cs

    r7100 r7183  
    2020#endregion
    2121
     22using System.Linq;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    3334  [Item("SymbolicTimeSeriesPrognosisSingleObjectiveValidationBestSolutionAnalyzer", "An operator that analyzes the validation best symbolic time-series prognosis solution for single objective symbolic time-series prognosis problems.")]
    3435  [StorableClass]
    35   public sealed class SymbolicTimeSeriesPrognosisSingleObjectiveValidationBestSolutionAnalyzer : SymbolicDataAnalysisSingleObjectiveValidationBestSolutionAnalyzer<ISymbolicTimeSeriesPrognosisSolution, ISymbolicTimeSeriesPrognosisSingleObjectiveEvaluator, ITimeSeriesPrognosisProblemData>,
    36     ISymbolicDataAnalysisBoundedOperator {
     36  public sealed class SymbolicTimeSeriesPrognosisSingleObjectiveValidationBestSolutionAnalyzer : SymbolicDataAnalysisSingleObjectiveValidationBestSolutionAnalyzer<ISymbolicTimeSeriesPrognosisSolution, ISymbolicTimeSeriesPrognosisSingleObjectiveEvaluator, ITimeSeriesPrognosisProblemData>, ISymbolicDataAnalysisBoundedOperator {
    3737    private const string EstimationLimitsParameterName = "EstimationLimits";
    3838    private const string ApplyLinearScalingParameterName = "ApplyLinearScaling";
    39 
    4039    #region parameter properties
    4140    public IValueLookupParameter<DoubleLimit> EstimationLimitsParameter {
     
    6160      Parameters.Add(new ValueParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the produced symbolic regression solution should be linearly scaled.", new BoolValue(true)));
    6261    }
    63 
    6462    public override IDeepCloneable Clone(Cloner cloner) {
    6563      return new SymbolicTimeSeriesPrognosisSingleObjectiveValidationBestSolutionAnalyzer(this, cloner);
     
    6765
    6866    protected override ISymbolicTimeSeriesPrognosisSolution CreateSolution(ISymbolicExpressionTree bestTree, double bestQuality) {
    69       var model = new SymbolicTimeSeriesPrognosisModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicTimeSeriesPrognosisInterpreterParameter.ActualValue);
     67      var model = new SymbolicTimeSeriesPrognosisModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, ProblemDataParameter.ActualValue.TargetVariables.ToArray(), EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper);
    7068      if (ApplyLinearScaling.Value)
    7169        SymbolicTimeSeriesPrognosisModel.Scale(model, ProblemDataParameter.ActualValue);
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SymbolicTimeSeriesPrognosisModel.cs

    r7154 r7183  
    3939      get { return HeuristicLab.Common.Resources.VSImageLibrary.Function; }
    4040    }
     41    [Storable(DefaultValue = double.MinValue)]
     42    private double lowerEstimationLimit;
     43    [Storable(DefaultValue = double.MaxValue)]
     44    private double upperEstimationLimit;
    4145
    4246    #region properties
     
    7276      this.targetVariables = new string[original.targetVariables.Length];
    7377      Array.Copy(original.targetVariables, this.targetVariables, this.targetVariables.Length);
    74     }
    75     public SymbolicTimeSeriesPrognosisModel(ISymbolicExpressionTree tree, ISymbolicTimeSeriesPrognosisExpressionTreeInterpreter interpreter, IEnumerable<string> targetVariables)
     78      this.lowerEstimationLimit = original.lowerEstimationLimit;
     79      this.upperEstimationLimit = original.upperEstimationLimit;
     80    }
     81    public SymbolicTimeSeriesPrognosisModel(ISymbolicExpressionTree tree, ISymbolicTimeSeriesPrognosisExpressionTreeInterpreter interpreter, IEnumerable<string> targetVariables, double lowerLimit = double.MinValue, double upperLimit = double.MaxValue)
    7682      : base() {
    7783      this.name = ItemName;
     
    7985      this.symbolicExpressionTree = tree;
    8086      this.interpreter = interpreter; this.targetVariables = targetVariables.ToArray();
     87      this.lowerEstimationLimit = lowerLimit;
     88      this.upperEstimationLimit = upperLimit;
    8189    }
    8290
     
    95103          for (int c = 0; c < components.Length; c++) {
    96104            enumerator.MoveNext();
    97             components[c] = enumerator.Current;
     105            components[c] = Math.Min(upperEstimationLimit, Math.Max(lowerEstimationLimit, enumerator.Current));
    98106          }
    99107          l.Add(components);
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs

    r6803 r7183  
    107107        if (tree.Root.SubtreeCount > 1)
    108108          this.treeChart.Tree = new SymbolicExpressionTree(tree.Root); // RPB + ADFs
     109        else if (tree.Root.GetSubtree(0).SubtreeCount > 1)
     110          this.treeChart.Tree = new SymbolicExpressionTree(tree.Root); // RPB
    109111        else
    110112          this.treeChart.Tree = new SymbolicExpressionTree(tree.Root.GetSubtree(0).GetSubtree(0)); // 1st child of RPB
     
    139141            if (tree.Root.SubtreeCount > 1)
    140142              this.treeChart.Tree = new SymbolicExpressionTree(tree.Root); // RPB + ADFs
     143            else if (tree.Root.GetSubtree(0).SubtreeCount > 1)
     144              this.treeChart.Tree = new SymbolicExpressionTree(tree.Root); // RPB
    141145            else
    142146              this.treeChart.Tree = new SymbolicExpressionTree(tree.Root.GetSubtree(0).GetSubtree(0)); // 1st child of RPB
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/TimeSeriesPrognosisSolutionView.Designer.cs

    r7160 r7183  
    7575      // itemsListView
    7676      //
    77       this.itemsListView.Size = new System.Drawing.Size(244, 240);
     77      this.itemsListView.Size = new System.Drawing.Size(244, 153);
    7878      //
    7979      // detailsGroupBox
    8080      //
    81       this.detailsGroupBox.Size = new System.Drawing.Size(266, 248);
     81      this.detailsGroupBox.Size = new System.Drawing.Size(266, 161);
    8282      //
    8383      // addButton
     
    9191      // viewHost
    9292      //
    93       this.viewHost.Size = new System.Drawing.Size(254, 223);
     93      this.viewHost.Size = new System.Drawing.Size(254, 136);
    9494      //
    9595      // horizonTextBox
     
    9999      this.horizonTextBox.Size = new System.Drawing.Size(100, 20);
    100100      this.horizonTextBox.TabIndex = 1;
     101      this.horizonTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.horizonTextBox_KeyDown);
    101102      this.horizonTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.horizonTextBox_Validating);
    102103      this.horizonTextBox.Validated += new System.EventHandler(this.horizonTextBox_Validated);
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/TimeSeriesPrognosisSolutionView.cs

    r7160 r7183  
    7373      Content.Horizon = val;
    7474    }
     75
     76    private void horizonTextBox_KeyDown(object sender, KeyEventArgs e) {
     77      if (e.KeyCode == Keys.Enter) {
     78        e.Handled = true;
     79        this.Focus();
     80      } else {
     81        e.Handled = false;
     82      }
     83    }
     84
    7585  }
    7686}
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionBase.cs

    r7160 r7183  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Concurrent;
    2324using System.Collections.Generic;
     
    195196    private void AfterDeserialization() {
    196197      if (horizon == 0) horizon = 1;
     198      bool anyNewResult = false;
     199      if (!ContainsKey(TrainingTheilsUStatisticLastResultName)) {
     200        Add(new Result(TrainingTheilsUStatisticLastResultName, "The average Theil's U statistic (reference: previous value) of the forecasts of the model on the training partition", new DoubleArray()));
     201        anyNewResult = true;
     202      }
     203      if (!ContainsKey(TestTheilsUStatisticLastResultName)) {
     204        Add(new Result(TestTheilsUStatisticLastResultName, "The average Theil's U statistic (reference: previous value) of the forecasts of the model on the test partition", new DoubleArray()));
     205        anyNewResult = true;
     206      }
     207      if (!ContainsKey(TrainingTheilsUStatisticMeanResultName)) {
     208        Add(new Result(TrainingTheilsUStatisticMeanResultName, "The average Theil's U statistic (reference: mean value) of the forecasts of the model on the training partition", new DoubleArray()));
     209        anyNewResult = true;
     210      }
     211      if (!ContainsKey(TestTheilsUStatisticMeanResultName)) {
     212        Add(new Result(TestTheilsUStatisticMeanResultName, "The average Theil's U statistic (reference: mean value) of the forecasts of the model on the test partition", new DoubleArray()));
     213        anyNewResult = true;
     214      }
     215      if (!ContainsKey(TrainingTheilsUStatisticMAResultName)) {
     216        Add(new Result(TrainingTheilsUStatisticMAResultName, "The average Theil's U statistic (reference: moving average) of the forecasts of the model on the training partition", new DoubleArray()));
     217        anyNewResult = true;
     218      }
     219      if (!ContainsKey(TestTheilsUStatisticMAResultName)) {
     220        Add(new Result(TestTheilsUStatisticMAResultName, "The average Theil's U statistic (reference: moving average) of the forecasts of the model on the test partition", new DoubleArray()));
     221        anyNewResult = true;
     222      }
     223      if (anyNewResult)
     224        RecalculateResults();
    197225    }
    198226
     
    240268      //double[] trainingTheilsU = new double[targetVariables.Length];
    241269      //double[] testTheilsU = new double[targetVariables.Length];
     270
     271      var trainingMseCalculators = new OnlineMeanSquaredErrorCalculator[targetVariables.Length];
     272      var testMseCalculators = new OnlineMeanSquaredErrorCalculator[targetVariables.Length];
     273      var trainingMaeCalculators = new OnlineMeanAbsoluteErrorCalculator[targetVariables.Length];
     274      var testMaeCalculators = new OnlineMeanAbsoluteErrorCalculator[targetVariables.Length];
     275      var trainingRSquaredCalculators = new OnlinePearsonsRSquaredCalculator[targetVariables.Length];
     276      var testRSquaredCalculators = new OnlinePearsonsRSquaredCalculator[targetVariables.Length];
     277      var trainingRelErrorCalculators = new OnlineMeanAbsolutePercentageErrorCalculator[targetVariables.Length];
     278      var testRelErrorCalculators = new OnlineMeanAbsolutePercentageErrorCalculator[targetVariables.Length];
     279      var trainingNmseCalculators = new OnlineNormalizedMeanSquaredErrorCalculator[targetVariables.Length];
     280      var testNmseCalculators = new OnlineNormalizedMeanSquaredErrorCalculator[targetVariables.Length];
    242281
    243282      var trainingDsCalculators = new OnlineDirectionalSymmetryCalculator[targetVariables.Length];
     
    252291      var testTheilsUMovingAverageCalculators = new OnlineTheilsUStatisticCalculator[targetVariables.Length];
    253292      for (int i = 0; i < targetVariables.Length; i++) {
     293        trainingMseCalculators[i] = new OnlineMeanSquaredErrorCalculator();
     294        testMseCalculators[i] = new OnlineMeanSquaredErrorCalculator();
     295        trainingMaeCalculators[i] = new OnlineMeanAbsoluteErrorCalculator();
     296        testMaeCalculators[i] = new OnlineMeanAbsoluteErrorCalculator();
     297        trainingRSquaredCalculators[i] = new OnlinePearsonsRSquaredCalculator();
     298        testRSquaredCalculators[i] = new OnlinePearsonsRSquaredCalculator();
     299        trainingRelErrorCalculators[i] = new OnlineMeanAbsolutePercentageErrorCalculator();
     300        testRelErrorCalculators[i] = new OnlineMeanAbsolutePercentageErrorCalculator();
     301        trainingNmseCalculators[i] = new OnlineNormalizedMeanSquaredErrorCalculator();
     302        testNmseCalculators[i] = new OnlineNormalizedMeanSquaredErrorCalculator();
     303
    254304        trainingDsCalculators[i] = new OnlineDirectionalSymmetryCalculator();
    255305        testDsCalculators[i] = new OnlineDirectionalSymmetryCalculator();
     
    286336            trainingTheilsUMeanCalculators[t].Add(startValue, actualContinuation.Select(x => mean), actualContinuation, prognosedContinuation);
    287337            trainingTheilsUMovingAverageCalculators[t].Add(startValue, movingAverageContinuation, actualContinuation, prognosedContinuation);
     338
     339            var actualContinuationEnumerator = actualContinuation.GetEnumerator();
     340            var prognosedContinuationEnumerator = prognosedContinuation.GetEnumerator();
     341            while (actualContinuationEnumerator.MoveNext() & prognosedContinuationEnumerator.MoveNext()) {
     342              trainingMseCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current);
     343              trainingMaeCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current);
     344              trainingRelErrorCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current);
     345              trainingRSquaredCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current);
     346              trainingNmseCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current);
     347            }
     348            if (actualContinuationEnumerator.MoveNext() | prognosedContinuationEnumerator.MoveNext())
     349              throw new ArgumentException(
     350                "Different number of elements in Actual continuation and prognosed continuation.");
    288351          }
    289352        }
     
    312375            testTheilsUMeanCalculators[t].Add(startValue, actualContinuation.Select(x => mean), actualContinuation, prognosedContinuation);
    313376            testTheilsUMovingAverageCalculators[t].Add(startValue, movingAverageContinuation, actualContinuation, prognosedContinuation);
     377
     378            var actualContinuationEnumerator = actualContinuation.GetEnumerator();
     379            var prognosedContinuationEnumerator = prognosedContinuation.GetEnumerator();
     380            while (actualContinuationEnumerator.MoveNext() & prognosedContinuationEnumerator.MoveNext()) {
     381              testMseCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current);
     382              testMaeCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current);
     383              testRelErrorCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current);
     384              testRSquaredCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current);
     385              testNmseCalculators[t].Add(actualContinuationEnumerator.Current, prognosedContinuationEnumerator.Current);
     386            }
     387            if (actualContinuationEnumerator.MoveNext() | prognosedContinuationEnumerator.MoveNext())
     388              throw new ArgumentException(
     389                "Different number of elements in Actual continuation and prognosed continuation.");
    314390          }
    315391        }
    316392      }
    317393
     394
     395      TrainingMeanSquaredError = trainingMseCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity)
     396        .ToArray();
     397      TestMeanSquaredError = testMseCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity)
     398        .ToArray();
     399      TrainingMeanAbsoluteError = trainingMaeCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity)
     400        .ToArray();
     401      TestMeanAbsoluteError = testMaeCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity)
     402        .ToArray();
     403      TrainingRelativeError = trainingRelErrorCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity)
     404        .ToArray();
     405      TestRelativeError = testRelErrorCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity)
     406        .ToArray();
     407      TrainingRSquared = trainingRSquaredCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : 0.0)
     408        .ToArray();
     409      TestRSquared = testRSquaredCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : 0.0)
     410        .ToArray();
     411      TrainingNormalizedMeanSquaredError = trainingNmseCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity)
     412        .ToArray();
     413      TestNormalizedMeanSquaredError = testNmseCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : double.PositiveInfinity)
     414        .ToArray();
     415
    318416      TrainingDirectionalSymmetry = trainingDsCalculators.Select(c => c.ErrorState == OnlineCalculatorError.None ? c.Value : 0.0)
    319417        .ToArray();
Note: See TracChangeset for help on using the changeset viewer.