Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7097


Ignore:
Timestamp:
11/29/11 18:26:55 (13 years ago)
Author:
gkronber
Message:

#1081: reverse merged r6802, r6807-6808, r6811, r6974, r7058 to prepare for the 3.3.6 release

Location:
trunk/sources
Files:
11 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab 3.3.sln

    r7084 r7097  
    8181    {E10F395F-C8A6-48AD-B470-9AA7A1F43809} = {E10F395F-C8A6-48AD-B470-9AA7A1F43809}
    8282    {B7A64A60-B538-479F-9C47-A3180C458F6C} = {B7A64A60-B538-479F-9C47-A3180C458F6C}
    83     {07486E68-1517-4B9D-A58D-A38E99AE71AB} = {07486E68-1517-4B9D-A58D-A38E99AE71AB}
    8483    {4AE3FC69-C575-42D2-BC46-0FAD5850EFC5} = {4AE3FC69-C575-42D2-BC46-0FAD5850EFC5}
    8584    {56F9106A-079F-4C61-92F6-86A84C2D84B7} = {56F9106A-079F-4C61-92F6-86A84C2D84B7}
     
    9392    {70DFD984-B1D9-46FE-8EB7-4DE92D71A9FC} = {70DFD984-B1D9-46FE-8EB7-4DE92D71A9FC}
    9493    {06D4A186-9319-48A0-BADE-A2058D462EEA} = {06D4A186-9319-48A0-BADE-A2058D462EEA}
    95     {5B9B9E8C-2706-43C2-80B8-A08341E431F7} = {5B9B9E8C-2706-43C2-80B8-A08341E431F7}
    9694    {997F018D-AEA2-4F21-9301-82FAF6A5612D} = {997F018D-AEA2-4F21-9301-82FAF6A5612D}
    9795    {D767C38D-8014-46B0-9A32-03A3AECCE34A} = {D767C38D-8014-46B0-9A32-03A3AECCE34A}
     
    116114    {66D249C3-A01D-42A8-82A2-919BC8EC3D83} = {66D249C3-A01D-42A8-82A2-919BC8EC3D83}
    117115    {E4CFB0C3-0589-4893-B38E-8BEDF885C765} = {E4CFB0C3-0589-4893-B38E-8BEDF885C765}
    118     {E6CB1FC5-78EC-4EB8-BF12-35303C36F962} = {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}
    119116    {79271BC8-4446-40E2-BB89-9BE4E17174FE} = {79271BC8-4446-40E2-BB89-9BE4E17174FE}
    120117    {7A2531CE-3F7C-4F13-BCCA-ED6DC27A7086} = {7A2531CE-3F7C-4F13-BCCA-ED6DC27A7086}
     
    299296EndProject
    300297Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.QuadraticAssignment.Algorithms-3.3", "HeuristicLab.Problems.QuadraticAssignment.Algorithms\3.3\HeuristicLab.Problems.QuadraticAssignment.Algorithms-3.3.csproj", "{5B9B9E8C-2706-43C2-80B8-A08341E431F7}"
    301 EndProject
    302 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis-3.4", "HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis-3.4.csproj", "{07486E68-1517-4B9D-A58D-A38E99AE71AB}"
    303 EndProject
    304 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis.Views-3.4", "HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis.Views\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis.Views-3.4.csproj", "{E6CB1FC5-78EC-4EB8-BF12-35303C36F962}"
    305298EndProject
    306299Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{C89ADA03-1DAC-406A-9C1F-128CC9986D80}"
     
    14411434    {5B9B9E8C-2706-43C2-80B8-A08341E431F7}.Release|x86.ActiveCfg = Release|x86
    14421435    {5B9B9E8C-2706-43C2-80B8-A08341E431F7}.Release|x86.Build.0 = Release|x86
    1443     {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
    1444     {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
    1445     {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Debug|x64.ActiveCfg = Debug|x64
    1446     {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Debug|x64.Build.0 = Debug|x64
    1447     {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Debug|x86.ActiveCfg = Debug|x86
    1448     {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Debug|x86.Build.0 = Debug|x86
    1449     {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
    1450     {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Release|Any CPU.Build.0 = Release|Any CPU
    1451     {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Release|x64.ActiveCfg = Release|x64
    1452     {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Release|x64.Build.0 = Release|x64
    1453     {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Release|x86.ActiveCfg = Release|x86
    1454     {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Release|x86.Build.0 = Release|x86
    1455     {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
    1456     {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Debug|Any CPU.Build.0 = Debug|Any CPU
    1457     {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Debug|x64.ActiveCfg = Debug|x64
    1458     {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Debug|x64.Build.0 = Debug|x64
    1459     {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Debug|x86.ActiveCfg = Debug|x86
    1460     {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Debug|x86.Build.0 = Debug|x86
    1461     {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Release|Any CPU.ActiveCfg = Release|Any CPU
    1462     {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Release|Any CPU.Build.0 = Release|Any CPU
    1463     {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Release|x64.ActiveCfg = Release|x64
    1464     {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Release|x64.Build.0 = Release|x64
    1465     {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Release|x86.ActiveCfg = Release|x86
    1466     {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Release|x86.Build.0 = Release|x86
    14671436    {B62872C1-6752-4758-9823-751A2D28C388}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
    14681437    {B62872C1-6752-4758-9823-751A2D28C388}.Debug|Any CPU.Build.0 = Debug|Any CPU
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj

    r7021 r7097  
    144144    </Compile>
    145145    <Compile Include="Linear\AlglibUtil.cs" />
    146     <Compile Include="Linear\LinearTimeSeriesPrognosis.cs" />
    147146    <Compile Include="Linear\LinearDiscriminantAnalysis.cs" />
    148147    <Compile Include="Linear\LinearRegression.cs">
     
    248247      <Private>False</Private>
    249248    </ProjectReference>
    250     <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis-3.4.csproj">
    251       <Project>{07486E68-1517-4B9D-A58D-A38E99AE71AB}</Project>
    252       <Name>HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis-3.4</Name>
    253       <Private>False</Private>
    254     </ProjectReference>
    255249    <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis.Symbolic\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj">
    256250      <Project>{3D28463F-EC96-4D82-AFEE-38BE91A0CA00}</Project>
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/AlglibUtil.cs

    r6802 r7097  
    2727  public static class AlglibUtil {
    2828    public static double[,] PrepareInputMatrix(Dataset dataset, IEnumerable<string> variables, IEnumerable<int> rows) {
    29       return PrepareInputMatrix(dataset, variables, rows, new int[] { 0 });
    30     }
     29      List<string> variablesList = variables.ToList();
     30      List<int> rowsList = rows.ToList();
    3131
    32     public static double[,] PrepareInputMatrix(Dataset dataset, IEnumerable<string> variables, IEnumerable<int> rows, IEnumerable<int> lags) {
    33       int maxLag = lags.Max();
    34 
    35       // drop last variable (target variable)
    36       List<string> inputVariablesList = variables
    37         .Reverse()
    38         .Skip(1)
    39         .Reverse()
    40         .ToList();
    41       string targetVariable = variables.Last();
    42       List<int> rowsList = rows.ToList();
    43       int nRows = rowsList.Count - maxLag;
    44       double[,] matrix = new double[nRows, inputVariablesList.Count * lags.Count() + 1];
     32      double[,] matrix = new double[rowsList.Count, variablesList.Count];
    4533
    4634      int col = 0;
    47       int row = 0;
    48       // input variables
    49       foreach (int lag in lags) {
    50         foreach (string column in inputVariablesList) {
    51           var values = dataset.GetDoubleValues(column, rows.Select(x => x - lag).Take(nRows));
    52           row = 0;
    53           foreach (var value in values) {
    54             if (row >= 0) {
    55               matrix[row, col] = value;
    56             }
    57             row++;
    58           }
    59           col++;
     35      foreach (string column in variables) {
     36        var values = dataset.GetDoubleValues(column, rows);
     37        int row = 0;
     38        foreach (var value in values) {
     39          matrix[row, col] = value;
     40          row++;
    6041        }
     42        col++;
    6143      }
    62       // target variable
    63       row = 0;
    64       foreach (var value in dataset.GetDoubleValues(targetVariable, rows).Take(nRows)) {
    65         matrix[row, col] = value;
    66         row++;
    67       }
     44
    6845      return matrix;
    6946    }
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Plugin.cs.frame

    r6866 r7097  
    4242  [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic.Classification", "3.4")]
    4343  [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression", "3.4")]
    44   [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis", "3.4")]
    4544  public class HeuristicLabAlgorithmsDataAnalysisPlugin : PluginBase {
    4645  }
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorRegression.cs

    r6802 r7097  
    143143      parameter.Probability = false;
    144144
     145
    145146      SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(dataset, targetVariable, allowedInputVariables, rows);
    146147      SVM.RangeTransform rangeTransform = SVM.RangeTransform.Compute(problem);
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionErrorCharacteristicsCurveView.cs

    r6807 r7097  
    6767      }
    6868
    69       var laggedVariables = Content.Model.SymbolicExpressionTree.IterateNodesPostfix()
    70         .OfType<LaggedVariableTreeNode>()
    71         .Select(n => n.Lag)
    72         .Where(l => l < 0);
    73       if (laggedVariables.Any()) throw new NotSupportedException("The symbolic regression solution contains lagged variables.");
    74 
    7569      //check inputVariables used in the symbolic regression model
    7670      var usedVariables =
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs

    r7071 r7097  
    194194      Symbols.Where(s => s.Name == TimeSeriesSymbolsName).First().Enabled = false;
    195195    }
    196 
    197     public void ConfigureAsDefaultTimeSeriesPrognosisGrammar() {
    198       Symbols.Where(s => s is Variable).First().Enabled = false;
    199       Symbols.Where(s => s.Name == TrigonometricFunctionsName).First().Enabled = false;
    200       Symbols.Where(s => s.Name == PowerFunctionsName).First().Enabled = false;
    201       Symbols.Where(s => s.Name == ConditionalSymbolsName).First().Enabled = false;
    202     }
    203196  }
    204197}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj

    r6866 r7097  
    122122      <DependentUpon>ClassificationEnsembleSolutionModelView.cs</DependentUpon>
    123123    </Compile>
    124     <Compile Include="Plugin.cs" />
    125     <Compile Include="Solution Views\TimeSeriesPrognosisSolutionView.cs">
    126       <SubType>UserControl</SubType>
    127     </Compile>
    128     <Compile Include="Solution Views\TimeSeriesPrognosisSolutionView.Designer.cs">
    129       <DependentUpon>TimeSeriesPrognosisSolutionView.cs</DependentUpon>
    130     </Compile>
    131     <Compile Include="TimeSeriesPrognosis\TimeSeriesPrognosisSolutionErrorCharacteristicsCurveView.cs">
    132       <SubType>UserControl</SubType>
    133     </Compile>
    134     <Compile Include="TimeSeriesPrognosis\TimeSeriesPrognosisSolutionErrorCharacteristicsCurveView.Designer.cs">
    135       <DependentUpon>TimeSeriesPrognosisSolutionErrorCharacteristicsCurveView.cs</DependentUpon>
    136     </Compile>
    137     <Compile Include="TimeSeriesPrognosis\TimeSeriesPrognosisSolutionLineChartView.cs">
    138       <SubType>UserControl</SubType>
    139     </Compile>
    140     <Compile Include="TimeSeriesPrognosis\TimeSeriesPrognosisSolutionLineChartView.Designer.cs">
    141       <DependentUpon>TimeSeriesPrognosisSolutionLineChartView.cs</DependentUpon>
    142     </Compile>
    143     <Compile Include="TimeSeriesPrognosis\TimeSeriesPrognosisSolutionPrognosedValuesView.cs">
    144       <SubType>UserControl</SubType>
    145     </Compile>
    146     <Compile Include="TimeSeriesPrognosis\TimeSeriesPrognosisSolutionPrognosedValuesView.Designer.cs">
    147       <DependentUpon>TimeSeriesPrognosisSolutionPrognosedValuesView.cs</DependentUpon>
    148     </Compile>
    149     <Compile Include="TimeSeriesPrognosis\TimeSeriesPrognosisSolutionScatterPlotView.cs">
    150       <SubType>UserControl</SubType>
    151     </Compile>
    152     <Compile Include="TimeSeriesPrognosis\TimeSeriesPrognosisSolutionScatterPlotView.Designer.cs">
    153       <DependentUpon>TimeSeriesPrognosisSolutionScatterPlotView.cs</DependentUpon>
    154     </Compile>
    155124    <Compile Include="DataAnalysisSolutionEvaluationView.cs">
    156125      <SubType>UserControl</SubType>
     
    159128      <DependentUpon>DataAnalysisSolutionEvaluationView.cs</DependentUpon>
    160129    </Compile>
     130    <Compile Include="Plugin.cs" />
    161131    <Compile Include="Regression\RegressionSolutionErrorCharacteristicsCurveView.cs">
    162132      <SubType>UserControl</SubType>
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj

    r7043 r7097  
    129129    </Compile>
    130130    <Compile Include="Implementation\Regression\RegressionEnsembleSolution.cs" />
    131     <Compile Include="Implementation\TimeSeriesPrognosis\TimeSeriesPrognosisProblem.cs" />
    132     <Compile Include="Implementation\TimeSeriesPrognosis\TimeSeriesPrognosisProblemData.cs" />
    133     <Compile Include="Implementation\TimeSeriesPrognosis\TimeSeriesPrognosisSolution.cs" />
    134     <Compile Include="Implementation\TimeSeriesPrognosis\TimeSeriesPrognosisSolutionBase.cs" />
    135131    <Compile Include="Interfaces\Classification\IClassificationEnsembleModel.cs">
    136132      <SubType>Code</SubType>
     
    145141    <Compile Include="Interfaces\Regression\IRegressionEnsembleSolution.cs" />
    146142    <Compile Include="Implementation\Regression\RegressionSolutionBase.cs" />
    147     <Compile Include="Interfaces\TimeSeriesPrognosis\IOnlineTimeSeriesCalculator.cs" />
    148     <Compile Include="Interfaces\TimeSeriesPrognosis\ITimeSeriesPrognosisModel.cs" />
    149     <Compile Include="Interfaces\TimeSeriesPrognosis\ITimeSeriesPrognosisProblem.cs" />
    150     <Compile Include="Interfaces\TimeSeriesPrognosis\ITimeSeriesPrognosisProblemData.cs" />
    151     <Compile Include="Interfaces\TimeSeriesPrognosis\ITimeSeriesPrognosisSolution.cs" />
    152143    <Compile Include="OnlineCalculators\NormalizedGiniCalculator.cs" />
    153     <Compile Include="OnlineCalculators\OnlineDirectionalSymmetryCalculator.cs" />
    154144    <Compile Include="OnlineCalculators\OnlineMeanAbsoluteErrorCalculator.cs" />
    155145    <Compile Include="OnlineCalculators\OnlineLinearScalingParameterCalculator.cs" />
     
    187177    <Compile Include="OnlineCalculators\OnlinePearsonsRSquaredCalculator.cs" />
    188178    <Compile Include="Implementation\Regression\RegressionSolution.cs" />
    189     <Compile Include="OnlineCalculators\OnlineTheilsUStatisticCalculator.cs" />
    190     <Compile Include="OnlineCalculators\OnlineWeightedDirectionalSymmetryCalculator.cs" />
    191179    <Compile Include="Plugin.cs" />
    192180    <Compile Include="TableFileParser.cs" />
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis-3.4/StatisticCalculatorsTest.cs

    r7058 r7097  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    2423using System.Linq;
     
    140139      }
    141140    }
    142 
    143     [TestMethod]
    144     public void CalculateDirectionalSymmetryTest() {
    145       // delta: +0.01, +1, -0.01, -2, -0.01, -1, +0.01, +2
    146       var original = new double[]
    147                        {
    148                          0,
    149                          0.01,
    150                          1.01,
    151                          1,
    152                          -1,
    153                          -1.01,
    154                          -2.01,
    155                          -2,
    156                          0
    157                        };
    158       // delta to original(t-1): +1, +0, -1, -0, -1, +0.01, +0.01, +2
    159       var estimated = new double[]
    160                         {
    161                           -1,
    162                           1,
    163                           0.01,
    164                           0.01,
    165                           1,
    166                           -1,
    167                           -1.02,
    168                           -2.02,
    169                           0
    170                         };
    171 
    172       // one-step forecast
    173       var startValues = original;
    174       var actualContinuations = from x in original.Skip(1)
    175                                 select Enumerable.Repeat(x, 1);
    176       var predictedContinuations = from x in estimated.Skip(1)
    177                                    select Enumerable.Repeat(x, 1);
    178       double expected = 0.5;  // half of the predicted deltas are correct
    179       OnlineCalculatorError errorState;
    180       double actual = OnlineDirectionalSymmetryCalculator.Calculate(startValues, actualContinuations, predictedContinuations, out errorState);
    181       Assert.AreEqual(expected, actual, 1E-9);
    182     }
    183 
    184     [TestMethod]
    185     public void CalculateMultiStepDirectionalSymmetryTest() {
    186       // delta: +0.01, +1, -0.01, -2, -0.01, -1, +0.01, +2
    187       var original = new double[] { 0, 0.01, 1.01, 1, -1, -1.01, -2.01, -2, 0 };
    188       {
    189         var estimated = new double[][]
    190                           {
    191                             new double[] {0.01, 1.01, 1, -1, -1.01},
    192                             new double[] {1.01, 1, -1, -1.01, -2.01},
    193                             new double[] {1, -1, -1.01, -2.01, -2},
    194                             new double[] {-1, -1.01, -2.01, -2, 0}
    195                           };
    196 
    197         // 5-step forecast
    198         var startValues = original.Take(4);
    199         var actualContinuations = from i in Enumerable.Range(1, original.Count() - 5)
    200                                   select original.Skip(i).Take(5);
    201         var predictedContinuations = estimated;
    202         double expected = 1; // predictions are 100% correct
    203         OnlineCalculatorError errorState;
    204         double actual = OnlineDirectionalSymmetryCalculator.Calculate(startValues, actualContinuations,
    205                                                                       predictedContinuations, out errorState);
    206         Assert.AreEqual(expected, actual, 1E-9);
    207       }
    208       {
    209         // only the direction is relevant
    210         var estimated = new double[][]
    211                           {
    212                             new double[] {0.01, 0.01, 0.01, -0.01, -0.01},  // start=0, original deltas: 0.01, 1.01, 1.00, -1.00, -1.01
    213                             new double[] {0.02, 0.02, 0.00, 0.00, 0.00}, // start=0.01, original deltas: 1.00, 0.90, -1.01, -1.02, -2.02,
    214                             new double[] { 1.00, 1.00, 1.00, 1.00, 1.00}, // start=1.01, original deltas: -0.01, -2.01, -2.02, -3.02, -3.01
    215                             new double[] { 0.90, 0.90, 0.90, 0.90, 0.90}  // start=1, original deltas: -2.00, -0.01, -3.01, -3.00, -1.00
    216                           };
    217 
    218         // 5-step forecast
    219         var startValues = original.Take(4);
    220         var actualContinuations = from i in Enumerable.Range(1, original.Count() - 5)
    221                                   select original.Skip(i).Take(5);
    222         var predictedContinuations = estimated;
    223         double expected = 1; // half of the predicted deltas are correct
    224         OnlineCalculatorError errorState;
    225         double actual = OnlineDirectionalSymmetryCalculator.Calculate(startValues, actualContinuations,
    226                                                                       predictedContinuations, out errorState);
    227         Assert.AreEqual(expected, actual, 1E-9);
    228       }
    229       {
    230         // also check incorrectly predicted directions
    231         var estimated = new double[][]
    232                           {
    233                             new double[] {0.01, 0.01, 0.01, +0.01, +0.01},  // start=0, original deltas: 0.01, 1.01, 1.00, -1.00, -1.01
    234                             new double[] {0.02, 0.00, 0.02, 0.00, 0.00}, // start=0.01, original deltas: 1.00, 0.90, -1.01, -1.02, -2.02,
    235                             new double[] { 1.02, 1.00, 1.02, 1.00, 1.02}, // start=1.01, original deltas: -0.01, -2.01, -2.02, -3.02, -3.01
    236                             new double[] { 0.90, 0.90, 0.90, 0.90, 0.90}  // start=1, original deltas: -2.00, -0.01, -3.01, -3.00, -1.00
    237                           };
    238 
    239         // 5-step forecast
    240         var startValues = original.Take(4);
    241         var actualContinuations = from i in Enumerable.Range(1, original.Count() - 5)
    242                                   select original.Skip(i).Take(5);
    243         var predictedContinuations = estimated;
    244         double expected = (20 - 7) / 20.0; // half of the predicted deltas are correct
    245         OnlineCalculatorError errorState;
    246         double actual = OnlineDirectionalSymmetryCalculator.Calculate(startValues, actualContinuations,
    247                                                                       predictedContinuations, out errorState);
    248         Assert.AreEqual(expected, actual, 1E-9);
    249       }
    250     }
    251 
    252 
    253     [TestMethod]
    254     public void CalculateWeightedDirectionalSymmetryTest() {
    255       var original = new double[] { 0, 0.01, 1.01, 1, -1, -1.01, -2.01, -2, 0 }; // +0.01, +1, -0.01, -2, -0.01, -1, +0.01, +2
    256       var estimated = new double[] { 1, 2, 2, 1, 1, 0, 0.01, 0.02, 2.02 }; // delta to original: +2, +1.99, -0.01, 0, +1, -1.02, +2.01, +4.02
    257       // one-step forecast
    258       var startValues = original;
    259       var actualContinuations = from x in original.Skip(1)
    260                                 select Enumerable.Repeat(x, 1);
    261       var predictedContinuations = from x in estimated.Skip(1)
    262                                    select Enumerable.Repeat(x, 1);
    263       // absolute errors = 1.99, 0.99, 0, 2, 1.01, 2.02, 2.02, 2.02     
    264       // sum of absolute errors for correctly predicted deltas = 2.97
    265       // sum of absolute errors for incorrectly predicted deltas = 3.03
    266       double expected = 5.03 / 7.02;
    267       OnlineCalculatorError errorState;
    268       double actual = OnlineWeightedDirectionalSymmetryCalculator.Calculate(startValues, actualContinuations, predictedContinuations, out errorState);
    269       Assert.AreEqual(expected, actual, 1E-9);
    270     }
    271 
    272     [TestMethod]
    273     public void CalculateTheilsUTest() {
    274       var original = new double[] { 0, 0.01, 1.01, 1, -1, -1.01, -2.01, -2, 0 };
    275       var estimated = new double[] { 1, 1.01, 0.01, 2, 0, -0.01, -1.01, -3, 1 };
    276       // one-step forecast
    277       var startValues = original;
    278       var actualContinuations = from x in original.Skip(1)
    279                                 select Enumerable.Repeat(x, 1);
    280       var predictedContinuations = from x in estimated.Skip(1)
    281                                    select Enumerable.Repeat(x, 1);
    282       // Sum of squared errors of model y(t+1) = y(t) = 10.0004
    283       // Sum of squared errors of predicted values = 8 
    284       double expected = Math.Sqrt(8 / 10.0004);
    285       OnlineCalculatorError errorState;
    286       double actual = OnlineTheilsUStatisticCalculator.Calculate(startValues, actualContinuations, predictedContinuations, out errorState);
    287       Assert.AreEqual(expected, actual, 1E-9);
    288     }
    289 
    290     [TestMethod]
    291     public void CalculateMultiStepTheilsUTest() {
    292       var original = new double[] { 0, 0.01, 1.01, 1, -1, -1.01, -2.01, -2, 0 };
    293       {
    294         // prefect prediction
    295         var estimated = new double[][]
    296                           {
    297                             new double[] {0.01, 1.01, 1, -1, -1.01},
    298                             new double[] {1.01, 1, -1, -1.01, -2.01},
    299                             new double[] {1, -1, -1.01, -2.01, -2},
    300                             new double[] {-1, -1.01, -2.01, -2, 0}
    301                           };
    302         // 5-step forecast
    303         var startValues = original.Take(4);
    304         var actualContinuations = from i in Enumerable.Range(1, original.Count() - 5)
    305                                   select original.Skip(i).Take(5);
    306         var predictedContinuations = estimated;
    307 
    308         double expected = 0;
    309         OnlineCalculatorError errorState;
    310         double actual = OnlineTheilsUStatisticCalculator.Calculate(startValues, actualContinuations,
    311                                                                    predictedContinuations, out errorState);
    312         Assert.AreEqual(expected, actual, 1E-9);
    313       }
    314       {
    315         // naive prediction
    316         var estimated = new double[][]
    317                           {
    318                             new double[] {0, 0, 0, 0, 0},
    319                             new double[] {0.01, 0.01, 0.01, 0.01, 0.01},
    320                             new double[] {1.01, 1.01, 1.01, 1.01, 1.01},
    321                             new double[] {1, 1, 1, 1, 1}
    322                           };
    323         // 5-step forecast
    324         var startValues = original.Take(4);
    325         var actualContinuations = from i in Enumerable.Range(1, original.Count() - 5)
    326                                   select original.Skip(i).Take(5);
    327         var predictedContinuations = estimated;
    328 
    329         double expected = 1;
    330         OnlineCalculatorError errorState;
    331         double actual = OnlineTheilsUStatisticCalculator.Calculate(startValues, actualContinuations,
    332                                                                    predictedContinuations, out errorState);
    333         Assert.AreEqual(expected, actual, 1E-9);
    334       }
    335       {
    336         // realistic prediction
    337         var estimated = new double[][]
    338                           {
    339                             new double[] {0.005, 0.5, 0.5, -0.5, -0.5},    // start = 0
    340                             new double[] {0.60, 0.5, -0.5, -0.5, -1},   // start = 0.01
    341                             new double[] {-0.005, 0, 0, -0.5, -1},     // start = 1.01
    342                             new double[] {-0, 0, -0.5, -1, 0.5}      // start = 1
    343                           };
    344         // 5-step forecast
    345         var startValues = original.Take(4);
    346         var actualContinuations = from i in Enumerable.Range(1, original.Count() - 5)
    347                                   select original.Skip(i).Take(5);
    348         var predictedContinuations = estimated;
    349 
    350         double expected = 0.47558387;
    351         OnlineCalculatorError errorState;
    352         double actual = OnlineTheilsUStatisticCalculator.Calculate(startValues, actualContinuations,
    353                                                                    predictedContinuations, out errorState);
    354         Assert.AreEqual(expected, actual, 1E-6);
    355       }
    356     }
    357 
    358     [TestMethod]
    359     public void CalculateAccuracyTest() {
    360       var original = new double[] { 1, 1, 0, 0 };
    361       var estimated = new double[] { 1, 0, 1, 0 };
    362       double expected = 0.5;
    363       OnlineCalculatorError errorState;
    364       double actual = OnlineAccuracyCalculator.Calculate(original, estimated, out errorState);
    365       Assert.AreEqual(expected, actual, 1E-9);
    366     }
    367 
    368     [TestMethod]
    369     public void CalculateMeanAbsolutePercentageErrorTest() {
    370       var original = new double[] { 1, 2, 3, 1, 5 };
    371       var estimated = new double[] { 2, 1, 3, 1, 0 };
    372       double expected = 0.5;
    373       OnlineCalculatorError errorState;
    374       double actual = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(original, estimated, out errorState);
    375       Assert.AreEqual(expected, actual, 1E-9);
    376       Assert.AreEqual(OnlineCalculatorError.None, errorState);
    377 
    378       // if the original contains zero values the result is not defined
    379       var original2 = new double[] { 1, 2, 0, 0, 0 };
    380       OnlineMeanAbsolutePercentageErrorCalculator.Calculate(original2, estimated, out errorState);
    381       Assert.AreEqual(OnlineCalculatorError.InvalidValueAdded, errorState);
    382     }
    383141  }
    384142}
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Tests.csproj

    r7055 r7097  
    830830      <Name>HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4</Name>
    831831    </ProjectReference>
    832     <ProjectReference Include="..\HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis.Views\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis.Views-3.4.csproj">
    833       <Project>{E6CB1FC5-78EC-4EB8-BF12-35303C36F962}</Project>
    834       <Name>HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis.Views-3.4</Name>
    835     </ProjectReference>
    836     <ProjectReference Include="..\HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis-3.4.csproj">
    837       <Project>{07486E68-1517-4B9D-A58D-A38E99AE71AB}</Project>
    838       <Name>HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis-3.4</Name>
    839     </ProjectReference>
    840832    <ProjectReference Include="..\HeuristicLab.Problems.DataAnalysis.Symbolic.Views\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj">
    841833      <Project>{7A2531CE-3F7C-4F13-BCCA-ED6DC27A7086}</Project>
Note: See TracChangeset for help on using the changeset viewer.