- Timestamp:
- 09/10/20 09:57:02 (4 years ago)
- Location:
- branches/3040_VectorBasedGP
- Files:
-
- 7 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3040_VectorBasedGP/HeuristicLab.Common/3.3/Statistics/EnumerableStatisticExtensions.cs
r17721 r17741 230 230 if (min > max) throw new ArgumentException(string.Format("Minimum {0} is larger than maximum {1}.", min, max)); 231 231 foreach (var x in values) { 232 /*if (double.IsNaN(x)) yield return (max + min) / 2.0; 233 else */ 234 if (x < min) yield return min; 232 if (double.IsNaN(x)) yield return (max + min) / 2.0; 233 else if (x < min) yield return min; 235 234 else if (x > max) yield return max; 236 235 else yield return x; -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveProblem.cs
r17180 r17741 118 118 119 119 private void UpdateEstimationLimits() { 120 if (ProblemData.TrainingIndices.Any() ) {120 if (ProblemData.TrainingIndices.Any() && ProblemData.Dataset.VariableHasType<double>(ProblemData.TargetVariable)) { 121 121 var targetValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).ToList(); 122 122 var mean = targetValues.Average(); -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis/3.4/ModifiableDataset.cs
r17180 r17741 141 141 if (values.Count != variableValues[variableName].Count) 142 142 throw new ArgumentException("The number of values must coincide with the number of dataset rows."); 143 if (GetVariableType(variableName) != values[0].GetType()) 143 //if (GetVariableType(variableName) != values[0].GetType()) 144 if (!GetVariableType(variableName).IsInstanceOfType(values[0])) 144 145 throw new ArgumentException("The type of the provided value does not match the variable type."); 145 146 variableValues[variableName] = values; -
branches/3040_VectorBasedGP/HeuristicLab.Problems.Instances.DataAnalysis/3.3/HeuristicLab.Problems.Instances.DataAnalysis-3.3.csproj
r17588 r17741 262 262 <Compile Include="Regression\VectorData\RandomExtensions.cs" /> 263 263 <Compile Include="Regression\VectorData\VectorDataInstanceProvider.cs" /> 264 <Compile Include="Regression\VectorData\VectorDataTestFour.cs" /> 264 265 <Compile Include="Regression\VectorData\VectorDataTestThree.cs" /> 265 266 <Compile Include="Regression\VectorData\VectorDataTestTwo.cs" /> -
branches/3040_VectorBasedGP/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/VectorData/AzzaliBenchmark3.cs
r17721 r17741 28 28 using HeuristicLab.Problems.DataAnalysis; 29 29 using HeuristicLab.Random; 30 30 using MathNet.Numerics.Statistics; 31 31 using DoubleVector = MathNet.Numerics.LinearAlgebra.Vector<double>; 32 32 … … 38 38 protected override string TargetVariable { get { return "B3"; } } 39 39 protected override string[] VariableNames { get { return AllowedInputVariables.Concat(new[] { TargetVariable }).ToArray(); } } 40 protected override string[] AllowedInputVariables { get { return new string[] { "X1", "X2", "X3", "X4" }; } }40 protected override string[] AllowedInputVariables { get { return new string[] { "X1", "X2", "X3", "X4", "X5" }; } } 41 41 protected override int TrainingPartitionStart { get { return 0; } } 42 42 protected override int TrainingPartitionEnd { get { return 70; } } … … 85 85 x3Column.Add(x3); 86 86 x4Column.Add(x4); 87 x5Column.Add(x5); 87 88 b3Column.Add(b3); 88 89 } -
branches/3040_VectorBasedGP/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/VectorData/AzzaliKorns5.cs
r17448 r17741 28 28 using HeuristicLab.Problems.DataAnalysis; 29 29 using HeuristicLab.Random; 30 30 using MathNet.Numerics.Statistics; 31 31 using DoubleVector = MathNet.Numerics.LinearAlgebra.Vector<double>; 32 32 -
branches/3040_VectorBasedGP/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/VectorData/VectorDataInstanceProvider.cs
r17588 r17741 62 62 new VectorDataTestThreeC(rand.Next()), 63 63 new VectorDataTestThreeD(rand.Next()), 64 new VectorDataTestFourA(rand.Next()), 65 new VectorDataTestFourB(rand.Next()), 66 new VectorDataTestFourC(rand.Next()), 67 new VectorDataTestFourD(rand.Next()), 64 68 new AzzaliBenchmark1(rand.Next()), 65 69 new AzzaliBenchmark2(rand.Next()), -
branches/3040_VectorBasedGP/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/VectorData/VectorDataTestFour.cs
r17725 r17741 30 30 31 31 namespace HeuristicLab.Problems.Instances.DataAnalysis { 32 public abstract class VectorDataTest One: ArtificialRegressionDataDescriptor {32 public abstract class VectorDataTestFour : ArtificialRegressionDataDescriptor { 33 33 34 protected const int Rows = 1000 ;34 protected const int Rows = 10000; 35 35 36 36 public override string Description { get { return ""; } } 37 37 38 38 protected override string TargetVariable { get { return "Y"; } } 39 protected override string[] VariableNames { get { return new string[] { "X1", "X2", "X3", " V1", "V2", "Y" }; } }40 protected override string[] AllowedInputVariables { get { return new string[] { "X1", "X2", "X3", " V1", "V2" }; } }39 protected override string[] VariableNames { get { return new string[] { "X1", "X2", "X3", "X4", "X5", "V1", "V2", "V3", "V4", "V5", "Y" }; } } 40 protected override string[] AllowedInputVariables { get { return new string[] { "X1", "X2", "X3", "X4", "X5", "V1", "V2", "V3", "V4", "V5" }; } } 41 41 protected override int TrainingPartitionStart { get { return 0; } } 42 42 protected override int TrainingPartitionEnd { get { return Rows * 3 / 4; } } … … 46 46 public int Seed { get; private set; } 47 47 48 protected VectorDataTest One()48 protected VectorDataTestFour() 49 49 : this((int)DateTime.Now.Ticks) { } 50 protected VectorDataTest One(int seed)50 protected VectorDataTestFour(int seed) 51 51 : base() { 52 52 Seed = seed; … … 58 58 var rand = new MersenneTwister((uint)Seed); 59 59 60 double x1, x2, x3 ;61 DoubleVector v1, v2 ;60 double x1, x2, x3, x4, x5; 61 DoubleVector v1, v2, v3, v4, v5; 62 62 double y; 63 63 … … 65 65 var x2Column = new List<double>(Rows); 66 66 var x3Column = new List<double>(Rows); 67 var x4Column = new List<double>(Rows); 68 var x5Column = new List<double>(Rows); 67 69 var v1Column = new List<DoubleVector>(Rows); 68 70 var v2Column = new List<DoubleVector>(Rows); 71 var v3Column = new List<DoubleVector>(Rows); 72 var v4Column = new List<DoubleVector>(Rows); 73 var v5Column = new List<DoubleVector>(Rows); 69 74 var yColumn = new List<double>(Rows); 70 75 … … 74 79 x2 = rand.NextDouble(2, 6); 75 80 x3 = rand.NextDouble(0, 1); 76 int v1Length = vectorLengths[0][i]; 77 int v2Length = vectorLengths[1][i]; 78 v1 = rand.NextDoubleVector(2, 6, v1Length); 79 v2 = rand.NextDoubleVector(3, 5, v2Length); 81 x4 = rand.NextDouble(30, 100); 82 x5 = rand.NextDouble(150, 200); 83 v1 = rand.NextDoubleVector(2, 6, vectorLengths[0][i]); 84 v2 = rand.NextDoubleVector(3, 5, vectorLengths[1][i]); 85 v3 = rand.NextDoubleVector(-10, 50, vectorLengths[2][i]); 86 v4 = rand.NextDoubleVector(0, 200, vectorLengths[3][i]); 87 v5 = rand.NextDoubleVector(200, 220, vectorLengths[4][i]); 80 88 81 y = x1 * v1.Sum() + x2 * v2.Mean(); 89 var t1 = ((v1 + Math.Log(10 * x5)) * (v4 - 50 * v2.PointwiseSin()).Mean() * x1).Mean() / 10; // mean 50 90 var t2 = (v5.StandardDeviation() + v2.PointwisePower(2.0)).Mean(); // mean 18 + 6 = 24 91 var t3 = Math.Exp(3 * x3) + v2.PointwiseMultiply(v3).Mean() / 10; // mean 7 + 8 = 15 92 y = t1 - 0.1 * t2 * t3; 82 93 83 94 x1Column.Add(x1); 84 95 x2Column.Add(x2); 85 96 x3Column.Add(x3); 97 x4Column.Add(x4); 98 x5Column.Add(x5); 86 99 v1Column.Add(v1); 87 100 v2Column.Add(v2); 101 v3Column.Add(v3); 102 v4Column.Add(v4); 103 v5Column.Add(v5); 88 104 yColumn.Add(y); 89 105 } 90 106 91 return new List<IList> { x1Column, x2Column, x3Column, v1Column, v2Column, yColumn }; 107 return new List<IList> { 108 x1Column, x2Column, x3Column, x4Column, x5Column, 109 v1Column, v2Column, v3Column, v4Column, v5Column, 110 yColumn 111 }; 92 112 } 93 113 … … 95 115 } 96 116 97 public class VectorDataTest OneA : VectorDataTestOne{117 public class VectorDataTestFourA : VectorDataTestFour { 98 118 public override string Name { 99 get { return "Vector Data Test - I [fully-constrained]: Y = X1 * sum(V1) + X2 * mean(V2)"; }119 get { return "Vector Data Test - IV [fully-constrained]: Y = X1 * sum(V1) + X2 * mean(V2)"; } 100 120 } 101 121 102 public VectorDataTest OneA() : base() { }103 public VectorDataTest OneA(int seed) : base(seed) { }122 public VectorDataTestFourA() : base() { } 123 public VectorDataTestFourA(int seed) : base(seed) { } 104 124 105 125 protected override List<int>[] GetVectorLengths(IRandom rand) { 106 126 // always same length 107 const int length = 5; 108 return new List<int>[2] { 127 const int length = 40; 128 return new List<int>[5] { 129 Enumerable.Repeat(length, Rows).ToList(), 130 Enumerable.Repeat(length, Rows).ToList(), 131 Enumerable.Repeat(length, Rows).ToList(), 109 132 Enumerable.Repeat(length, Rows).ToList(), 110 133 Enumerable.Repeat(length, Rows).ToList() … … 113 136 } 114 137 115 public class VectorDataTest OneB : VectorDataTestOne{116 public override string Name { get { return "Vector Data Test - I [row-constrained]: Y = X1 * sum(V1) + X2 * mean(V2)"; } }138 public class VectorDataTestFourB : VectorDataTestFour { 139 public override string Name { get { return "Vector Data Test - IV [row-constrained]: Y = X1 * sum(V1) + X2 * mean(V2)"; } } 117 140 118 public VectorDataTest OneB() : base() { }119 public VectorDataTest OneB(int seed) : base(seed) { }141 public VectorDataTestFourB() : base() { } 142 public VectorDataTestFourB(int seed) : base(seed) { } 120 143 121 144 protected override List<int>[] GetVectorLengths(IRandom rand) { 122 // length between length 4 and 8, same row always the same length 123 var lengths = Enumerable.Range(0, Rows).Select(i => rand.Next(4, 8)).ToList(); 124 return new List<int>[2] { 145 // length between length 40 and 80, same row always the same length 146 var lengths = Enumerable.Range(0, Rows).Select(i => rand.Next(40, 80)).ToList(); 147 return new List<int>[5] { 148 Enumerable.Range(0, Rows).Select(i => lengths[i]).ToList(), 149 Enumerable.Range(0, Rows).Select(i => lengths[i]).ToList(), 150 Enumerable.Range(0, Rows).Select(i => lengths[i]).ToList(), 125 151 Enumerable.Range(0, Rows).Select(i => lengths[i]).ToList(), 126 152 Enumerable.Range(0, Rows).Select(i => lengths[i]).ToList() … … 129 155 } 130 156 131 public class VectorDataTest OneC : VectorDataTestOne{132 public override string Name { get { return "Vector Data Test - I [column-constrained]: Y = X1 * sum(V1) + X2 * mean(V2)"; } }157 public class VectorDataTestFourC : VectorDataTestFour { 158 public override string Name { get { return "Vector Data Test - IV [column-constrained]: Y = X1 * sum(V1) + X2 * mean(V2)"; } } 133 159 134 public VectorDataTest OneC() : base() { }135 public VectorDataTest OneC(int seed) : base(seed) { }160 public VectorDataTestFourC() : base() { } 161 public VectorDataTestFourC(int seed) : base(seed) { } 136 162 137 163 protected override List<int>[] GetVectorLengths(IRandom rand) { 138 // length between length 4 and 8; each feature is same length 139 // force two different lengths 140 int v1Length = rand.Next(4, 8); 164 // length between length 40 and 80; each feature is same length 165 int v1Length = rand.Next(40, 80); 141 166 int v2Length; 142 do { 143 v2Length = rand.Next(4, 8); 144 } while (v1Length != v2Length); 145 return new List<int>[2] { 167 do { v2Length = rand.Next(40, 80); } while (v1Length != v2Length); 168 int v3Length = rand.Next(40, 80); 169 int v4Length; 170 do { v4Length = rand.Next(40, 80); } while (v3Length != v4Length); 171 int v5Length = rand.Next(40, 80); 172 return new List<int>[5] { 146 173 Enumerable.Repeat(v1Length, Rows).ToList(), 147 Enumerable.Repeat(v2Length, Rows).ToList() 174 Enumerable.Repeat(v2Length, Rows).ToList(), 175 Enumerable.Repeat(v3Length, Rows).ToList(), 176 Enumerable.Repeat(v4Length, Rows).ToList(), 177 Enumerable.Repeat(v5Length, Rows).ToList() 148 178 }; 149 179 } 150 180 } 151 181 152 public class VectorDataTest OneD : VectorDataTestOne{153 public override string Name { get { return "Vector Data Test - I [unconstrained]: Y = X1 * sum(V1) + X2 * mean(V2)"; } }182 public class VectorDataTestFourD : VectorDataTestFour { 183 public override string Name { get { return "Vector Data Test - IV [unconstrained]: Y = X1 * sum(V1) + X2 * mean(V2)"; } } 154 184 155 public VectorDataTest OneD() : base() { }156 public VectorDataTest OneD(int seed) : base(seed) { }185 public VectorDataTestFourD() : base() { } 186 public VectorDataTestFourD(int seed) : base(seed) { } 157 187 158 188 protected override List<int>[] GetVectorLengths(IRandom rand) { 159 // always random between 4 and 8 160 return new List<int>[2] { 161 Enumerable.Range(0, Rows).Select(i => rand.Next(4, 8)).ToList(), 162 Enumerable.Range(0, Rows).Select(i => rand.Next(4, 8)).ToList() 163 }; 189 // always random between 40 and 80 190 return new List<int>[5] { 191 Enumerable.Range(0, Rows).Select(i => rand.Next(40, 80)).ToList(), 192 Enumerable.Range(0, Rows).Select(i => rand.Next(40, 80)).ToList(), 193 Enumerable.Range(0, Rows).Select(i => rand.Next(40, 80)).ToList(), 194 Enumerable.Range(0, Rows).Select(i => rand.Next(40, 80)).ToList(), 195 Enumerable.Range(0, Rows).Select(i => rand.Next(40, 80)).ToList() 196 }; 164 197 } 165 198 }
Note: See TracChangeset
for help on using the changeset viewer.