Changeset 6991 for branches/RegressionBenchmarks/HeuristicLab.Problems.DataAnalysis.Benchmarks/3.4/RegressionBenchmarks/KotanchekFunction.cs
- Timestamp:
- 11/14/11 17:08:32 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RegressionBenchmarks/HeuristicLab.Problems.DataAnalysis.Benchmarks/3.4/RegressionBenchmarks/KotanchekFunction.cs
r6968 r6991 31 31 public class KotanchekFunction : RegressionBenchmark { 32 32 33 private const string targetVariable = "Y"; 34 private static readonly List<string> inputVariables = new List<string>() { "X1", "X2" }; 35 private static readonly IntRange trainingPartition = new IntRange(0, 1000); 36 private static readonly IntRange testPartition = new IntRange(1001, 2000); 37 38 public override List<string> InputVariable { 39 get { return inputVariables; } 40 } 41 42 public override string TargetVariable { 43 get { return targetVariable; } 44 } 45 46 public override IntRange TrainingPartition { 47 get { return trainingPartition; } 48 } 49 50 public override IntRange TestPartition { 51 get { return testPartition; } 52 } 53 33 54 public KotanchekFunction() { 34 55 Name = "Kotanchek function (2d)"; 35 TargetVariable = "y";36 Inputvariables = new Dictionary<string, IntRange>() {37 {"x1", new IntRange(0, 4)},38 {"x2", new IntRange(0, 4)}39 };40 AmountOfPoints = 4000;41 TrainingPartition = new IntRange(0, 2667);42 TestPartition = new IntRange(TrainingPartition.End, AmountOfPoints);43 56 } 44 57 … … 53 66 #endregion 54 67 55 protected override double CalculateFunction(Dictionary<string, IList<double>> data, List<string> vars) { 56 double x1 = data[vars.ElementAt(0)].Last(); 57 double x2 = data[vars.ElementAt(1)].Last(); 58 return Math.Exp(-Math.Pow(x1 - 1, 2)) / (Math.Pow(x2 - 2.5, 2) + 3.2); 68 protected override List<double> CalculateFunction(Dictionary<string, IList<double>> data) { 69 double x1, x2; 70 List<double> results = new List<double>(); 71 for (int i = 0; i < TestPartition.End; i++) { 72 x1 = data[InputVariable.ElementAt(0)].ElementAt(i); 73 x2 = data[InputVariable.ElementAt(1)].ElementAt(i); 74 results.Add(Math.Exp(-Math.Pow(x1 - 1, 2)) / (Math.Pow(x2 - 2.5, 2) + 3.2)); 75 } 76 return results; 77 } 78 79 protected override Dictionary<string, IList<double>> GenerateInput(Dictionary<string, IList<double>> data) { 80 foreach (var variable in InputVariable) { 81 data[variable] = RegressionBenchmark.generateUniformDistributedValues(TestPartition.End, new DoubleRange(0, 4)); 82 } 83 data[TargetVariable] = CalculateFunction(data); 84 return data; 59 85 } 60 86 }
Note: See TracChangeset
for help on using the changeset viewer.