Changeset 7097 for trunk/sources
- Timestamp:
- 11/29/11 18:26:55 (13 years ago)
- Location:
- trunk/sources
- Files:
-
- 11 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab 3.3.sln
r7084 r7097 81 81 {E10F395F-C8A6-48AD-B470-9AA7A1F43809} = {E10F395F-C8A6-48AD-B470-9AA7A1F43809} 82 82 {B7A64A60-B538-479F-9C47-A3180C458F6C} = {B7A64A60-B538-479F-9C47-A3180C458F6C} 83 {07486E68-1517-4B9D-A58D-A38E99AE71AB} = {07486E68-1517-4B9D-A58D-A38E99AE71AB}84 83 {4AE3FC69-C575-42D2-BC46-0FAD5850EFC5} = {4AE3FC69-C575-42D2-BC46-0FAD5850EFC5} 85 84 {56F9106A-079F-4C61-92F6-86A84C2D84B7} = {56F9106A-079F-4C61-92F6-86A84C2D84B7} … … 93 92 {70DFD984-B1D9-46FE-8EB7-4DE92D71A9FC} = {70DFD984-B1D9-46FE-8EB7-4DE92D71A9FC} 94 93 {06D4A186-9319-48A0-BADE-A2058D462EEA} = {06D4A186-9319-48A0-BADE-A2058D462EEA} 95 {5B9B9E8C-2706-43C2-80B8-A08341E431F7} = {5B9B9E8C-2706-43C2-80B8-A08341E431F7}96 94 {997F018D-AEA2-4F21-9301-82FAF6A5612D} = {997F018D-AEA2-4F21-9301-82FAF6A5612D} 97 95 {D767C38D-8014-46B0-9A32-03A3AECCE34A} = {D767C38D-8014-46B0-9A32-03A3AECCE34A} … … 116 114 {66D249C3-A01D-42A8-82A2-919BC8EC3D83} = {66D249C3-A01D-42A8-82A2-919BC8EC3D83} 117 115 {E4CFB0C3-0589-4893-B38E-8BEDF885C765} = {E4CFB0C3-0589-4893-B38E-8BEDF885C765} 118 {E6CB1FC5-78EC-4EB8-BF12-35303C36F962} = {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}119 116 {79271BC8-4446-40E2-BB89-9BE4E17174FE} = {79271BC8-4446-40E2-BB89-9BE4E17174FE} 120 117 {7A2531CE-3F7C-4F13-BCCA-ED6DC27A7086} = {7A2531CE-3F7C-4F13-BCCA-ED6DC27A7086} … … 299 296 EndProject 300 297 Project("{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 EndProject302 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 EndProject304 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}"305 298 EndProject 306 299 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{C89ADA03-1DAC-406A-9C1F-128CC9986D80}" … … 1441 1434 {5B9B9E8C-2706-43C2-80B8-A08341E431F7}.Release|x86.ActiveCfg = Release|x86 1442 1435 {5B9B9E8C-2706-43C2-80B8-A08341E431F7}.Release|x86.Build.0 = Release|x86 1443 {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU1444 {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Debug|Any CPU.Build.0 = Debug|Any CPU1445 {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Debug|x64.ActiveCfg = Debug|x641446 {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Debug|x64.Build.0 = Debug|x641447 {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Debug|x86.ActiveCfg = Debug|x861448 {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Debug|x86.Build.0 = Debug|x861449 {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Release|Any CPU.ActiveCfg = Release|Any CPU1450 {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Release|Any CPU.Build.0 = Release|Any CPU1451 {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Release|x64.ActiveCfg = Release|x641452 {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Release|x64.Build.0 = Release|x641453 {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Release|x86.ActiveCfg = Release|x861454 {07486E68-1517-4B9D-A58D-A38E99AE71AB}.Release|x86.Build.0 = Release|x861455 {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Debug|Any CPU.ActiveCfg = Debug|Any CPU1456 {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Debug|Any CPU.Build.0 = Debug|Any CPU1457 {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Debug|x64.ActiveCfg = Debug|x641458 {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Debug|x64.Build.0 = Debug|x641459 {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Debug|x86.ActiveCfg = Debug|x861460 {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Debug|x86.Build.0 = Debug|x861461 {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Release|Any CPU.ActiveCfg = Release|Any CPU1462 {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Release|Any CPU.Build.0 = Release|Any CPU1463 {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Release|x64.ActiveCfg = Release|x641464 {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Release|x64.Build.0 = Release|x641465 {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Release|x86.ActiveCfg = Release|x861466 {E6CB1FC5-78EC-4EB8-BF12-35303C36F962}.Release|x86.Build.0 = Release|x861467 1436 {B62872C1-6752-4758-9823-751A2D28C388}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 1468 1437 {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 144 144 </Compile> 145 145 <Compile Include="Linear\AlglibUtil.cs" /> 146 <Compile Include="Linear\LinearTimeSeriesPrognosis.cs" />147 146 <Compile Include="Linear\LinearDiscriminantAnalysis.cs" /> 148 147 <Compile Include="Linear\LinearRegression.cs"> … … 248 247 <Private>False</Private> 249 248 </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>255 249 <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis.Symbolic\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj"> 256 250 <Project>{3D28463F-EC96-4D82-AFEE-38BE91A0CA00}</Project> -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/AlglibUtil.cs
r6802 r7097 27 27 public static class AlglibUtil { 28 28 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(); 31 31 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]; 45 33 46 34 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++; 60 41 } 42 col++; 61 43 } 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 68 45 return matrix; 69 46 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Plugin.cs.frame
r6866 r7097 42 42 [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic.Classification", "3.4")] 43 43 [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression", "3.4")] 44 [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis", "3.4")]45 44 public class HeuristicLabAlgorithmsDataAnalysisPlugin : PluginBase { 46 45 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorRegression.cs
r6802 r7097 143 143 parameter.Probability = false; 144 144 145 145 146 SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(dataset, targetVariable, allowedInputVariables, rows); 146 147 SVM.RangeTransform rangeTransform = SVM.RangeTransform.Compute(problem); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionErrorCharacteristicsCurveView.cs
r6807 r7097 67 67 } 68 68 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 75 69 //check inputVariables used in the symbolic regression model 76 70 var usedVariables = -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs
r7071 r7097 194 194 Symbols.Where(s => s.Name == TimeSeriesSymbolsName).First().Enabled = false; 195 195 } 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 }203 196 } 204 197 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj
r6866 r7097 122 122 <DependentUpon>ClassificationEnsembleSolutionModelView.cs</DependentUpon> 123 123 </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>155 124 <Compile Include="DataAnalysisSolutionEvaluationView.cs"> 156 125 <SubType>UserControl</SubType> … … 159 128 <DependentUpon>DataAnalysisSolutionEvaluationView.cs</DependentUpon> 160 129 </Compile> 130 <Compile Include="Plugin.cs" /> 161 131 <Compile Include="Regression\RegressionSolutionErrorCharacteristicsCurveView.cs"> 162 132 <SubType>UserControl</SubType> -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj
r7043 r7097 129 129 </Compile> 130 130 <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" />135 131 <Compile Include="Interfaces\Classification\IClassificationEnsembleModel.cs"> 136 132 <SubType>Code</SubType> … … 145 141 <Compile Include="Interfaces\Regression\IRegressionEnsembleSolution.cs" /> 146 142 <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" />152 143 <Compile Include="OnlineCalculators\NormalizedGiniCalculator.cs" /> 153 <Compile Include="OnlineCalculators\OnlineDirectionalSymmetryCalculator.cs" />154 144 <Compile Include="OnlineCalculators\OnlineMeanAbsoluteErrorCalculator.cs" /> 155 145 <Compile Include="OnlineCalculators\OnlineLinearScalingParameterCalculator.cs" /> … … 187 177 <Compile Include="OnlineCalculators\OnlinePearsonsRSquaredCalculator.cs" /> 188 178 <Compile Include="Implementation\Regression\RegressionSolution.cs" /> 189 <Compile Include="OnlineCalculators\OnlineTheilsUStatisticCalculator.cs" />190 <Compile Include="OnlineCalculators\OnlineWeightedDirectionalSymmetryCalculator.cs" />191 179 <Compile Include="Plugin.cs" /> 192 180 <Compile Include="TableFileParser.cs" /> -
trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis-3.4/StatisticCalculatorsTest.cs
r7058 r7097 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 23 using System.Linq; … … 140 139 } 141 140 } 142 143 [TestMethod]144 public void CalculateDirectionalSymmetryTest() {145 // delta: +0.01, +1, -0.01, -2, -0.01, -1, +0.01, +2146 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 0157 };158 // delta to original(t-1): +1, +0, -1, -0, -1, +0.01, +0.01, +2159 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 0170 };171 172 // one-step forecast173 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 correct179 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, +2187 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 forecast198 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% correct203 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 relevant210 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.01213 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.01215 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.00216 };217 218 // 5-step forecast219 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 correct224 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 directions231 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.01234 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.01236 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.00237 };238 239 // 5-step forecast240 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 correct245 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, +2256 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.02257 // one-step forecast258 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.02264 // sum of absolute errors for correctly predicted deltas = 2.97265 // sum of absolute errors for incorrectly predicted deltas = 3.03266 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 forecast277 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.0004283 // Sum of squared errors of predicted values = 8284 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 prediction295 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 forecast303 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 prediction316 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 forecast324 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 prediction337 var estimated = new double[][]338 {339 new double[] {0.005, 0.5, 0.5, -0.5, -0.5}, // start = 0340 new double[] {0.60, 0.5, -0.5, -0.5, -1}, // start = 0.01341 new double[] {-0.005, 0, 0, -0.5, -1}, // start = 1.01342 new double[] {-0, 0, -0.5, -1, 0.5} // start = 1343 };344 // 5-step forecast345 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 defined379 var original2 = new double[] { 1, 2, 0, 0, 0 };380 OnlineMeanAbsolutePercentageErrorCalculator.Calculate(original2, estimated, out errorState);381 Assert.AreEqual(OnlineCalculatorError.InvalidValueAdded, errorState);382 }383 141 } 384 142 } -
trunk/sources/HeuristicLab.Tests/HeuristicLab.Tests.csproj
r7055 r7097 830 830 <Name>HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4</Name> 831 831 </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>840 832 <ProjectReference Include="..\HeuristicLab.Problems.DataAnalysis.Symbolic.Views\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj"> 841 833 <Project>{7A2531CE-3F7C-4F13-BCCA-ED6DC27A7086}</Project>
Note: See TracChangeset
for help on using the changeset viewer.