Changeset 8463 for trunk/sources/HeuristicLab.Tests
- Timestamp:
- 08/09/12 16:32:44 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Tests
- Files:
-
- 2 added
- 2 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/GaussianProcessFunctionsTest.cs
r8455 r8463 123 123 ); 124 124 125 //prod.Factors.Clear();126 //prod.Factors.Add(new MeanConst());127 //prod.Factors.Add(new MeanLinear());128 //TestMeanFunction(prod, 1,129 // new double[] { 2.9087, 1.8646, 3.1971, 1.9889, 1.7639, 1.2801, 2.8059, 3.7243, 3.1901, 1.4979},130 //new double[][]131 //{132 // new double[] { 1.8436, 2.1279, 3.1166, 1.6886, 3.2505, 2.9613, 2.3260, 1.7293, 1.7697, 2.3982},133 // new double[] { 0.6443, 0.3786, 0.8116, 0.5328, 0.3507, 0.9390, 0.8759, 0.5502, 0.6225, 0.5870},134 // new double[] { 0.2077, 0.3012, 0.4709, 0.2305, 0.8443, 0.1948, 0.2259, 0.1707, 0.2277, 0.4357},135 // new double[] { 0.3111, 0.9234, 0.4302, 0.1848, 0.9049, 0.9797, 0.4389, 0.1111, 0.2581, 0.4087},136 // new double[] { 0.5949, 0.2622, 0.6028, 0.7112, 0.2217, 0.1174, 0.2967, 0.3188, 0.4242, 0.5079},137 // new double[] { 0.0855, 0.2625, 0.8010, 0.0292, 0.9289, 0.7303, 0.4886, 0.5785, 0.2373, 0.4588 }138 //}139 //);125 prod.Factors.Clear(); 126 prod.Factors.Add(new MeanConst()); 127 prod.Factors.Add(new MeanLinear()); 128 TestMeanFunction(prod, 1, 129 new double[] { 1.843574580675791, 2.127929337522181, 3.116568910281474, 1.688566127130978, 3.250517738447450, 2.961262743634280, 2.326019412613392, 1.729286976436201, 1.769654419215176, 2.398170347588917 }, 130 new double[][] 131 { 132 new double[] { 2.9088, 1.8646, 3.1971, 1.9890, 1.7640, 1.2801, 2.8059, 3.7243, 3.1899 ,1.4978 }, 133 new double[] { 0.4173, 0.0497, 0.9027, 0.9448, 0.4909, 0.4893, 0.3377, 0.9001, 0.3692 ,0.1112 }, 134 new double[] { 0.7803, 0.3897, 0.2417, 0.4039, 0.0965, 0.1320, 0.9421, 0.9561, 0.5752 ,0.0598 }, 135 new double[] { 0.2348, 0.3532, 0.8212, 0.0154, 0.0430, 0.1690, 0.6491, 0.7317, 0.6477 ,0.4509 }, 136 new double[] { 0.5470, 0.2963, 0.7447, 0.1890, 0.6868, 0.1835, 0.3685, 0.6256, 0.7802 ,0.0811 }, 137 new double[] { 0.9294, 0.7757, 0.4868, 0.4359, 0.4468, 0.3063, 0.5085, 0.5108, 0.8176 ,0.7948 } 138 } 139 ); 140 140 } 141 141 -
trunk/sources/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/GaussianProcessRegressionTest.cs
r8455 r8463 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.Linq; 25 24 using System.Threading; 26 25 using HeuristicLab.Algorithms.DataAnalysis; 27 26 using HeuristicLab.Common; 28 using HeuristicLab.Core;29 27 using HeuristicLab.Problems.DataAnalysis; 30 using HeuristicLab. SequentialEngine;28 using HeuristicLab.Problems.Instances.DataAnalysis; 31 29 using Microsoft.VisualStudio.TestTools.UnitTesting; 32 30 33 namespace HeuristicLab _33.Tests {31 namespace HeuristicLab.Algorithms.DataAnalysis_34.Tests { 34 32 [TestClass] 33 [DeploymentItem(@"HeuristicLab.Algorithms.DataAnalysis-3.4/co2.txt")] 35 34 public class GaussianProcessRegressionTest { 36 35 public GaussianProcessRegressionTest() { } … … 58 57 ex = null; 59 58 60 var cv = new CrossValidation();61 59 var alg = new GaussianProcessRegression(); 62 alg.Engine = new SequentialEngine(); 63 cv.Algorithm = alg; 60 alg.Engine = new HeuristicLab.SequentialEngine.SequentialEngine(); 64 61 65 cv.Problem = new RegressionProblem();66 var rand = new HeuristicLab.Random.MersenneTwister();67 double[,] data = GenerateData(100, rand);68 List<string> variables = new List<string>() { "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10", "y" };69 Dataset ds = new Dataset(variables, data);70 cv.Problem.ProblemDataParameter.ActualValue = new RegressionProblemData(ds, variables.Take(10), variables.Last());71 cv.Algorithm.Prepare();72 cv.Folds.Value = 5;73 cv.SamplesStart.Value = 0;74 cv.SamplesEnd.Value = 99;62 alg.Problem = new RegressionProblem(); 63 var provider = new RegressionCSVInstanceProvider(); 64 var problemData = (RegressionProblemData)provider.ImportData("co2.txt"); 65 problemData.TargetVariableParameter.ActualValue = problemData.TargetVariableParameter.ValidValues.First(x => x.Value == "interpolated"); 66 problemData.InputVariables.SetItemCheckedState(problemData.InputVariables.First(x => x.Value == "year"), false); 67 problemData.InputVariables.SetItemCheckedState(problemData.InputVariables.First(x => x.Value == "month"), false); 68 problemData.InputVariables.SetItemCheckedState(problemData.InputVariables.First(x => x.Value == "average"), false); 69 problemData.InputVariables.SetItemCheckedState(problemData.InputVariables.First(x => x.Value == "interpolated"), false); 70 problemData.InputVariables.SetItemCheckedState(problemData.InputVariables.First(x => x.Value == "trend"), false); 71 problemData.InputVariables.SetItemCheckedState(problemData.InputVariables.First(x => x.Value == "#days"), false); 75 72 76 cv.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(cv_ExceptionOccurred); 77 cv.Stopped += new EventHandler(cv_Stopped); 73 alg.Problem.ProblemDataParameter.Value = problemData; 78 74 79 cv.Prepare(); 80 cv.Start(); 75 alg.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(cv_ExceptionOccurred); 76 alg.Stopped += new EventHandler(cv_Stopped); 77 78 alg.Prepare(); 79 alg.Start(); 81 80 trigger.WaitOne(); 82 81 if (ex != null) throw ex; 83 82 84 TestContext.WriteLine("Runtime: {0}", cv.ExecutionTime.ToString()); 85 86 } 87 88 // poly-10: y = x1 x2 + x3 x4 + x5 x6 + x1 x7 x9 + x3 x6 x10 89 private double[,] GenerateData(int n, IRandom random) { 90 double[,] data = new double[n, 11]; 91 for (int i = 0; i < n; i++) { 92 for (int c = 0; c < 10; c++) { 93 data[i, c] = random.NextDouble() * 2.0 - 1.0; 94 } 95 data[i, 10] = 96 data[i, 0] * data[i, 1] + 97 data[i, 2] * data[i, 3] + 98 data[i, 4] * data[i, 5] + 99 data[i, 0] * data[i, 6] * data[i, 8] + 100 data[i, 2] * data[i, 5] * data[i, 9]; 101 } 102 return data; 83 TestContext.WriteLine("Runtime: {0}", alg.ExecutionTime.ToString()); 103 84 } 104 85 -
trunk/sources/HeuristicLab.Tests/HeuristicLab.Tests.csproj
r8439 r8463 279 279 <Compile Include="HeuristicLab-3.3\ContentViewTests.cs" /> 280 280 <Compile Include="HeuristicLab-3.3\ParameterVisibilityTest.cs" /> 281 <Compile Include="HeuristicLab-3.3\GaussianProcessRegressionTest.cs" />282 281 <Compile Include="HeuristicLab-3.3\DeepCloneableCloningTest.cs" /> 283 282 <Compile Include="HeuristicLab-3.3\GeneticAlgorithmTest.cs" /> … … 290 289 <Compile Include="HeuristicLab-3.3\ThreadSafeLogTest.cs" /> 291 290 <Compile Include="HeuristicLab-3.3\ToStringTest.cs" /> 291 <Compile Include="HeuristicLab.Algorithms.DataAnalysis-3.4\GaussianProcessModelTest.cs" /> 292 292 <Compile Include="HeuristicLab.Algorithms.DataAnalysis-3.4\GaussianProcessFunctionsTest.cs" /> 293 <Compile Include="HeuristicLab.Algorithms.DataAnalysis-3.4\GaussianProcessRegressionTest.cs" /> 293 294 <Compile Include="HeuristicLab.Analysis-3.3\MultidimensionalScalingTest.cs" /> 294 295 <Compile Include="HeuristicLab.Encodings.BinaryVectorEncoding-3.3\Auxiliary.cs" /> … … 388 389 </ItemGroup> 389 390 <ItemGroup> 391 <Content Include="HeuristicLab.Algorithms.DataAnalysis-3.4\co2.txt"> 392 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 393 </Content> 390 394 <None Include="app.config" /> 391 395 <None Include="Builder.testsettings">
Note: See TracChangeset
for help on using the changeset viewer.