Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Various/FriedmanTwo.cs @ 7860

Last change on this file since 7860 was 7860, checked in by sforsten, 12 years ago

#1784:

  • added additional Keijzer problem instances
  • capitalized names real world problem instances
  • added Friedman I and II
  • added link to VariousInstanceProvider
  • changed symbol of info button for ProblemInstanceProvider in ProblemInstanceConsumerView
  • added CSVProvider for classification and regression problems
  • ProblemInstanceProviderViewGeneric only shows controls to load problem instances, if the selected ProblemInstanceProvider contains IDataDescriptor
File size: 2.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Linq;
25using HeuristicLab.Random;
26
27namespace HeuristicLab.Problems.Instances.DataAnalysis {
28  public class FriedmanTwo : ArtificialRegressionDataDescriptor {
29
30    public override string Name { get { return "Friedman - II"; } }
31    public override string Description {
32      get {
33        return "Paper: Multivariate Adaptive Regression Splines" + Environment.NewLine
34        + "Authors: Jerome H. Friedman";
35      }
36    }
37    protected override string TargetVariable { get { return "Y"; } }
38    protected override string[] InputVariables { get { return new string[] { "X1", "X2", "X3", "X4", "X5", "Y" }; } }
39    protected override string[] AllowedInputVariables { get { return new string[] { "X1", "X2", "X3", "X4", "X5" }; } }
40    protected override int TrainingPartitionStart { get { return 0; } }
41    protected override int TrainingPartitionEnd { get { return 5000; } }
42    protected override int TestPartitionStart { get { return 5000; } }
43    protected override int TestPartitionEnd { get { return 10000; } }
44
45    protected static FastRandom rand = new FastRandom();
46
47    protected override List<List<double>> GenerateValues() {
48      List<List<double>> data = new List<List<double>>();
49      for (int i = 0; i < AllowedInputVariables.Count(); i++) {
50        data.Add(ValueGenerator.GenerateUniformDistributedValues(10000, 0, 1).ToList());
51      }
52
53      double x1, x2, x3, x4, x5;
54      double f;
55      List<double> results = new List<double>();
56      for (int i = 0; i < data[0].Count; i++) {
57        x1 = data[0][i];
58        x2 = data[1][i];
59        x3 = data[2][i];
60        x4 = data[3][i];
61        x5 = data[4][i];
62
63        f = 10 * Math.Sin(Math.PI * x1 * x2) + 20 * Math.Pow(x3 - 0.5, 2) + 10 * x4 + 5 * x5;
64
65        results.Add(f + NormalDistributedRandom.NextDouble(rand, 0, 1));
66      }
67      data.Add(results);
68
69      return data;
70    }
71  }
72}
Note: See TracBrowser for help on using the repository browser.