Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/14/11 17:08:32 (13 years ago)
Author:
sforsten
Message:

#1669: First version with a simpler design as discussed with Michael Kommenda has been implemented and will be tested soon. Currently only the KotanchekFunction.cs is changed accordingly. Other benchmarks are going to follow soon.

The classes for the different distributions are not needed any longer. Static methods in RegressionBenchmark replace them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/RegressionBenchmarks/HeuristicLab.Problems.DataAnalysis.Benchmarks/3.4/RegressionBenchmarks/KotanchekFunction.cs

    r6968 r6991  
    3131  public class KotanchekFunction : RegressionBenchmark {
    3232
     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
    3354    public KotanchekFunction() {
    3455      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);
    4356    }
    4457
     
    5366    #endregion
    5467
    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;
    5985    }
    6086  }
Note: See TracChangeset for help on using the changeset viewer.