Changeset 14117
- Timestamp:
- 07/19/16 16:53:37 (8 years ago)
- Location:
- stable
- Files:
-
- 8 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 13939,13963,14110
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.Instances.DataAnalysis
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis merged: 13939,13963,14110
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.Instances.DataAnalysis/3.3/HeuristicLab.Problems.Instances.DataAnalysis-3.3.csproj
r13973 r14117 105 105 </PropertyGroup> 106 106 <ItemGroup> 107 <Reference Include="ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 108 <SpecificVersion>False</SpecificVersion> 109 <HintPath>..\..\bin\ALGLIB-3.7.0.dll</HintPath> 110 </Reference> 107 111 <Reference Include="System" /> 108 112 <Reference Include="System.Core" /> … … 147 151 <Compile Include="Regression\FeatureSelection\FeatureSelection.cs" /> 148 152 <Compile Include="Regression\FeatureSelection\FeatureSelectionInstanceProvider.cs" /> 153 <Compile Include="Regression\VariableNetworks\VariableNetwork.cs" /> 154 <Compile Include="Regression\VariableNetworks\VariableNetworkInstanceProvider.cs" /> 149 155 <Compile Include="Regression\Keijzer\KeijzerFunctionFourteen.cs" /> 150 156 <Compile Include="Regression\Keijzer\KeijzerFunctionEleven.cs" /> … … 179 185 <Compile Include="Regression\Korns\KornsFunctionTwo.cs" /> 180 186 <Compile Include="Regression\Korns\KornsInstanceProvider.cs" /> 187 <Compile Include="Regression\Friedman\FriedmanRandomFunction.cs" /> 188 <Compile Include="Regression\Friedman\FriedmanRandomFunctionInstanceProvider.cs" /> 181 189 <Compile Include="Regression\Nguyen\NguyenFunctionEight.cs" /> 182 190 <Compile Include="Regression\Nguyen\NguyenFunctionEleven.cs" /> -
stable/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Plugin.cs.frame
r13316 r14117 25 25 [Plugin("HeuristicLab.Problems.Instances.DataAnalysis", "3.3.13.$WCREV$")] 26 26 [PluginFile("HeuristicLab.Problems.Instances.DataAnalysis-3.3.dll", PluginFileType.Assembly)] 27 [PluginDependency("HeuristicLab.ALGLIB", "3.7")] 27 28 [PluginDependency("HeuristicLab.Common", "3.3")] 28 29 [PluginDependency("HeuristicLab.Collections", "3.3")] -
stable/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Friedman/FriedmanRandomFunction.cs
r13939 r14117 29 29 namespace HeuristicLab.Problems.Instances.DataAnalysis { 30 30 public class FriedmanRandomFunction : ArtificialRegressionDataDescriptor { 31 private int nTrainingSamples;32 private int nTestSamples;31 private readonly int nTrainingSamples; 32 private readonly int nTestSamples; 33 33 34 private int numberOfFeatures;35 private double noiseRatio;36 private IRandom random;34 private readonly int numberOfFeatures; 35 private readonly double noiseRatio; 36 private readonly IRandom random; 37 37 38 38 public override string Name { get { return string.Format("FriedmanRandomFunction-{0:0%} ({1} dim)", noiseRatio, numberOfFeatures); } } -
stable/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Friedman/FriedmanRandomFunctionInstanceProvider.cs
r13939 r14117 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 24 using System.Linq; 25 25 using HeuristicLab.Problems.DataAnalysis; 26 26 using HeuristicLab.Random; … … 53 53 54 54 public override IRegressionProblemData LoadData(IDataDescriptor descriptor) { 55 var varNetwork= descriptor as FriedmanRandomFunction;56 if ( varNetwork== null) throw new ArgumentException("FriedmanRandomFunctionInstanceProvider expects an FriedmanRandomFunction data descriptor.");55 var frfDescriptor = descriptor as FriedmanRandomFunction; 56 if (frfDescriptor == null) throw new ArgumentException("FriedmanRandomFunctionInstanceProvider expects an FriedmanRandomFunction data descriptor."); 57 57 // base call generates a regression problem data 58 var regProblemData = base.LoadData(varNetwork); 59 var problemData = 60 new RegressionProblemData( 61 regProblemData.Dataset, regProblemData.AllowedInputVariables, regProblemData.TargetVariable); 62 63 // copy values from regProblemData to feature selection problem data 64 problemData.Name = regProblemData.Name; 65 problemData.Description = regProblemData.Description; 66 problemData.TrainingPartition.Start = regProblemData.TrainingPartition.Start; 67 problemData.TrainingPartition.End = regProblemData.TrainingPartition.End; 68 problemData.TestPartition.Start = regProblemData.TestPartition.Start; 69 problemData.TestPartition.End = regProblemData.TestPartition.End; 70 58 var problemData = base.LoadData(frfDescriptor); 71 59 return problemData; 72 60 } -
stable/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/VariableNetworks/VariableNetwork.cs
r13939 r14117 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Text;26 25 using HeuristicLab.Common; 27 26 using HeuristicLab.Core; … … 86 85 87 86 protected override List<List<double>> GenerateValues() { 88 // var shuffledIdx = Enumerable.Range(0, numberOfFeatures).Shuffle(random).ToList();89 90 87 // variable names are shuffled in the beginning (and sorted at the end) 91 88 variableNames = variableNames.Shuffle(random).ToArray(); 92 89 93 // a third of all variables are independen vars90 // a third of all variables are independent vars 94 91 List<List<double>> lvl0 = new List<List<double>>(); 95 92 int numLvl0 = (int)Math.Ceiling(numberOfFeatures * 0.33); 96 93 97 94 List<string> description = new List<string>(); // store information how the variable is actually produced 95 List<string[]> inputVarNames = new List<string[]>(); // store information to produce graphviz file 98 96 99 97 var nrand = new NormalDistributedRandom(random, 0, 1); 100 98 for (int c = 0; c < numLvl0; c++) { 101 99 var datai = Enumerable.Range(0, TestPartitionEnd).Select(_ => nrand.NextDouble()).ToList(); 100 inputVarNames.Add(new string[] { }); 102 101 description.Add("~ N(0, 1)"); 103 102 lvl0.Add(datai); … … 108 107 int numLvl1 = (int)Math.Ceiling(numberOfFeatures * 0.33); 109 108 for (int c = 0; c < numLvl1; c++) { 110 string desc;111 var x = GenerateRandomFunction(random, lvl0, out desc);109 string[] selectedVarNames; 110 var x = GenerateRandomFunction(random, lvl0, out selectedVarNames); 112 111 var sigma = x.StandardDeviation(); 113 112 var noisePrng = new NormalDistributedRandom(random, 0, sigma * Math.Sqrt(noiseRatio / (1.0 - noiseRatio))); 114 113 lvl1.Add(x.Select(t => t + noisePrng.NextDouble()).ToList()); 114 115 inputVarNames.Add(selectedVarNames); 116 var desc = string.Format("f({0})", string.Join(",", selectedVarNames)); 115 117 description.Add(string.Format(" ~ N({0}, {1:N3})", desc, noisePrng.Sigma)); 116 118 } … … 120 122 int numLvl2 = (int)Math.Ceiling(numberOfFeatures * 0.2); 121 123 for (int c = 0; c < numLvl2; c++) { 122 string desc;123 var x = GenerateRandomFunction(random, lvl0.Concat(lvl1).ToList(), out desc);124 string[] selectedVarNames; 125 var x = GenerateRandomFunction(random, lvl0.Concat(lvl1).ToList(), out selectedVarNames); 124 126 var sigma = x.StandardDeviation(); 125 127 var noisePrng = new NormalDistributedRandom(random, 0, sigma * Math.Sqrt(noiseRatio / (1.0 - noiseRatio))); 126 128 lvl2.Add(x.Select(t => t + noisePrng.NextDouble()).ToList()); 129 130 inputVarNames.Add(selectedVarNames); 131 var desc = string.Format("f({0})", string.Join(",", selectedVarNames)); 127 132 description.Add(string.Format(" ~ N({0}, {1:N3})", desc, noisePrng.Sigma)); 128 133 } … … 132 137 int numLvl3 = numberOfFeatures - numLvl0 - numLvl1 - numLvl2; 133 138 for (int c = 0; c < numLvl3; c++) { 134 string desc;135 var x = GenerateRandomFunction(random, lvl0.Concat(lvl1).Concat(lvl2).ToList(), out desc);139 string[] selectedVarNames; 140 var x = GenerateRandomFunction(random, lvl0.Concat(lvl1).Concat(lvl2).ToList(), out selectedVarNames); 136 141 var sigma = x.StandardDeviation(); 137 142 var noisePrng = new NormalDistributedRandom(random, 0, sigma * Math.Sqrt(noiseRatio / (1.0 - noiseRatio))); 138 143 lvl3.Add(x.Select(t => t + noisePrng.NextDouble()).ToList()); 144 145 inputVarNames.Add(selectedVarNames); 146 var desc = string.Format("f({0})", string.Join(",", selectedVarNames)); 139 147 description.Add(string.Format(" ~ N({0}, {1:N3})", desc, noisePrng.Sigma)); 140 148 } 149 150 networkDefinition = string.Join(Environment.NewLine, variableNames.Zip(description, (n, d) => n + d)); 151 // for graphviz 152 networkDefinition += Environment.NewLine + "digraph G {"; 153 foreach (var t in variableNames.Zip(inputVarNames, Tuple.Create).OrderBy(t => t.Item1)) { 154 var name = t.Item1; 155 var selectedVarNames = t.Item2; 156 foreach (var selectedVarName in selectedVarNames) { 157 networkDefinition += Environment.NewLine + selectedVarName + " -> " + name; 158 } 159 } 160 networkDefinition += Environment.NewLine + "}"; 141 161 142 162 // return a random permutation of all variables 143 163 var allVars = lvl0.Concat(lvl1).Concat(lvl2).Concat(lvl3).ToList(); 144 networkDefinition = string.Join(Environment.NewLine, variableNames.Zip(description, (n, d) => n + d));145 164 var orderedVars = allVars.Zip(variableNames, Tuple.Create).OrderBy(t => t.Item2).Select(t => t.Item1).ToList(); 146 165 variableNames = variableNames.OrderBy(n => n).ToArray(); … … 149 168 150 169 // sample the input variables that are actually used and sample from a Gaussian process 151 private IEnumerable<double> GenerateRandomFunction(IRandom rand, List<List<double>> xs, out string desc) { 152 int nRows = xs.First().Count; 153 170 private IEnumerable<double> GenerateRandomFunction(IRandom rand, List<List<double>> xs, out string[] selectedVarNames) { 154 171 double r = -Math.Log(1.0 - rand.NextDouble()) * 2.0; // r is exponentially distributed with lambda = 2 155 172 int nl = (int)Math.Floor(1.5 + r); // number of selected vars is likely to be between three and four … … 160 177 161 178 var selectedVars = selectedIdx.Select(i => xs[i]).ToArray(); 162 desc = string.Format("f({0})", string.Join(",", selectedIdx.Select(i => VariableNames[i])));179 selectedVarNames = selectedIdx.Select(i => VariableNames[i]).ToArray(); 163 180 return SampleGaussianProcess(random, selectedVars); 164 181 } … … 171 188 // sample length-scales 172 189 var l = Enumerable.Range(0, nl) 173 .Select(_ => random.NextDouble() *2+0.5)190 .Select(_ => random.NextDouble() * 2 + 0.5) 174 191 .ToArray(); 175 192 // calculate covariance matrix -
stable/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/VariableNetworks/VariableNetworkInstanceProvider.cs
r13939 r14117 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 24 using System.Linq; 25 25 using HeuristicLab.Problems.DataAnalysis; 26 26 using HeuristicLab.Random; … … 56 56 if (varNetwork == null) throw new ArgumentException("VariableNetworkInstanceProvider expects an VariableNetwork data descriptor."); 57 57 // base call generates a regression problem data 58 var regProblemData = base.LoadData(varNetwork); 59 var problemData = 60 new RegressionProblemData( 61 regProblemData.Dataset, regProblemData.AllowedInputVariables, regProblemData.TargetVariable); 62 63 // copy values from regProblemData to feature selection problem data 64 problemData.Name = regProblemData.Name; 58 var problemData = base.LoadData(varNetwork); 65 59 problemData.Description = varNetwork.Description + Environment.NewLine + varNetwork.NetworkDefinition; 66 problemData.TrainingPartition.Start = regProblemData.TrainingPartition.Start;67 problemData.TrainingPartition.End = regProblemData.TrainingPartition.End;68 problemData.TestPartition.Start = regProblemData.TestPartition.Start;69 problemData.TestPartition.End = regProblemData.TestPartition.End;70 71 60 return problemData; 72 61 }
Note: See TracChangeset
for help on using the changeset viewer.