- Timestamp:
- 04/27/21 10:40:49 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/ShapeConstrainedRegressionProblemData.cs
r17961 r17964 35 35 protected const string ShapeConstraintsParameterName = "ShapeConstraints"; 36 36 37 private static double[,] kozaF1 = new double[,] { 38 {2.017885919, -1.449165046}, 39 {1.30060506, -1.344523885}, 40 {1.147134798, -1.317989331}, 41 {0.877182504, -1.266142284}, 42 {0.852562452, -1.261020794}, 43 {0.431095788, -1.158793317}, 44 {0.112586002, -1.050908405}, 45 {0.04594507, -1.021989402}, 46 {0.042572879, -1.020438113}, 47 {-0.074027291, -0.959859562}, 48 {-0.109178553, -0.938094706}, 49 {-0.259721109, -0.803635355}, 50 {-0.272991057, -0.387519561}, 51 {-0.161978191, -0.193611001}, 52 {-0.102489983, -0.114215349}, 53 {-0.01469968, -0.014918985}, 54 {-0.008863365, -0.008942626}, 55 {0.026751057, 0.026054094}, 56 {0.166922436, 0.14309643}, 57 {0.176953808, 0.1504144}, 58 {0.190233418, 0.159916534}, 59 {0.199800708, 0.166635331}, 60 {0.261502822, 0.207600348}, 61 {0.30182879, 0.232370249}, 62 {0.83763905, 0.468046718} 37 private static double[,] sigmoid = new double[,] { 38 {1.00, 0.09, 0.01390952}, 39 {1.10, 0.11, 0.048256016}, 40 {1.20, 0.14, 0.010182641}, 41 {1.30, 0.17, 0.270361269}, 42 {1.40, 0.20, 0.091503971}, 43 {1.50, 0.24, 0.338157191}, 44 {1.60, 0.28, 0.328508579}, 45 {1.70, 0.34, 0.21867684}, 46 {1.80, 0.40, 0.34515433}, 47 {1.90, 0.46, 0.562746903}, 48 {2.00, 0.54, 0.554800831}, 49 {2.10, 0.62, 0.623018787}, 50 {2.20, 0.71, 0.626224329}, 51 {2.30, 0.80, 0.909006688}, 52 {2.40, 0.90, 0.92514929}, 53 {2.50, 1.00, 1.097199936}, 54 {2.60, 1.10, 1.138309608}, 55 {2.70, 1.20, 1.087880692}, 56 {2.80, 1.29, 1.370491683}, 57 {2.90, 1.38, 1.422048792}, 58 {3.00, 1.46, 1.505242141}, 59 {3.10, 1.54, 1.684790135}, 60 {3.20, 1.60, 1.480232277}, 61 {3.30, 1.66, 1.577412501}, 62 {3.40, 1.72, 1.664822534}, 63 {3.50, 1.76, 1.773580664}, 64 {3.60, 1.80, 1.941034478}, 65 {3.70, 1.83, 1.730361986}, 66 {3.80, 1.86, 1.9785952}, 67 {3.90, 1.89, 1.946698641}, 68 {4.00, 1.91, 1.766502803}, 69 {4.10, 1.92, 1.847756843}, 70 {4.20, 1.94, 1.894506213}, 71 {4.30, 1.95, 2.029194724}, 72 {4.40, 1.96, 2.01830679}, 73 {4.50, 1.96, 1.924316332}, 74 {4.60, 1.97, 1.971354792}, 75 {4.70, 1.98, 1.85665728}, 76 {4.80, 1.98, 1.831400496}, 77 {4.90, 1.98, 2.057843156}, 78 {5.00, 1.99, 2.128769896}, 63 79 }; 64 80 … … 66 82 private static readonly IEnumerable<string> defaultAllowedInputVariables; 67 83 private static readonly string defaultTargetVariable; 84 private static readonly ShapeConstraints defaultShapeConstraints; 85 private static readonly IntervalCollection defaultVariableRanges; 68 86 69 87 private static readonly ShapeConstrainedRegressionProblemData emptyProblemData; 70 public new static ShapeConstrainedRegressionProblemData EmptyProblemData { 71 get { return emptyProblemData; } 72 } 88 public new static ShapeConstrainedRegressionProblemData EmptyProblemData => emptyProblemData; 73 89 74 90 static ShapeConstrainedRegressionProblemData() { 75 defaultDataset = new Dataset(new string[] { "y", "x" }, kozaF1); 76 defaultDataset.Name = "Fourth-order Polynomial Function Benchmark Dataset"; 77 defaultDataset.Description = "f(x) = x^4 + x^3 + x^2 + x^1"; 91 defaultDataset = new Dataset(new string[] { "x", "y", "y_noise" }, sigmoid) { 92 Name = "Sigmoid function to show shape-constrained symbolic regression.", 93 Description = "f(x) = 1 + tanh(x - 2.5)" 94 }; 78 95 defaultAllowedInputVariables = new List<string>() { "x" }; 79 defaultTargetVariable = "y"; 96 defaultTargetVariable = "y_noise"; 97 defaultShapeConstraints = new ShapeConstraints { 98 new ShapeConstraint(new Interval(0, 2), 1.0), 99 new ShapeConstraint("x", 1, new Interval(0, double.PositiveInfinity), 1.0) 100 }; 101 defaultVariableRanges = defaultDataset.GetIntervals(); 102 defaultVariableRanges.SetInterval("x", new Interval(0, 6)); 103 80 104 var problemData = new ShapeConstrainedRegressionProblemData(); 81 problemData.Parameters.Clear(); // parameters are cleared and added below because we cannot set / change parameters of ProblemData105 problemData.Parameters.Clear(); 82 106 problemData.Name = "Empty Regression ProblemData"; 83 107 problemData.Description = "This ProblemData acts as place holder before the correct problem data is loaded."; … … 94 118 } 95 119 96 public IFixedValueParameter<ShapeConstraints> ShapeConstraint sParameter => (IFixedValueParameter<ShapeConstraints>)Parameters[ShapeConstraintsParameterName];97 public ShapeConstraints ShapeConstraints => ShapeConstraint sParameter.Value;120 public IFixedValueParameter<ShapeConstraints> ShapeConstraintParameter => (IFixedValueParameter<ShapeConstraints>)Parameters[ShapeConstraintsParameterName]; 121 public ShapeConstraints ShapeConstraints => ShapeConstraintParameter.Value; 98 122 99 123 [StorableConstructor] … … 109 133 } 110 134 public override IDeepCloneable Clone(Cloner cloner) { 111 if (this == emptyProblemData) return emptyProblemData; 112 return new ShapeConstrainedRegressionProblemData(this, cloner); 135 return this == emptyProblemData ? emptyProblemData : new ShapeConstrainedRegressionProblemData(this, cloner); 113 136 } 114 137 115 138 public ShapeConstrainedRegressionProblemData() : this(defaultDataset, defaultAllowedInputVariables, defaultTargetVariable, 116 139 trainingPartition: new IntRange(0, defaultDataset.Rows), 117 testPartition: new IntRange(0, 0) ) { } // no test partition for the demo problem140 testPartition: new IntRange(0, 0), sc: defaultShapeConstraints, variableRanges: defaultVariableRanges) { } // no test partition for the demo problem 118 141 119 142 public ShapeConstrainedRegressionProblemData(IRegressionProblemData regressionProblemData)
Note: See TracChangeset
for help on using the changeset viewer.