Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/Various/FriedmanOne.cs @ 15016

Last change on this file since 15016 was 14229, checked in by gkronber, 8 years ago

#2371: removed usage of C# 6.0 readonly properties

File size: 3.0 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2016 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 FriedmanOne : ArtificialRegressionDataDescriptor {
29
30    public override string Name { get { return "Friedman - I"; } }
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[] VariableNames { get { return new string[] { "X1", "X2", "X3", "X4", "X5", "X6", "X7", "X8", "X9", "X10", "Y" }; } }
39    protected override string[] AllowedInputVariables { get { return new string[] { "X1", "X2", "X3", "X4", "X5", "X6", "X7", "X8", "X9", "X10" }; } }
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    public int Seed { get; private set; }
45
46    public FriedmanOne() : this((int)DateTime.Now.Ticks) { }
47
48    public FriedmanOne(int seed) : base() {
49      Seed = seed;
50    }
51
52    protected override List<List<double>> GenerateValues() {
53      List<List<double>> data = new List<List<double>>();
54      var rand = new MersenneTwister((uint)Seed);
55      for (int i = 0; i < AllowedInputVariables.Count(); i++) {
56        data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), 10000, 0, 1).ToList());
57      }
58
59      double x1, x2, x3, x4, x5;
60      double f;
61      List<double> results = new List<double>();
62      for (int i = 0; i < data[0].Count; i++) {
63        x1 = data[0][i];
64        x2 = data[1][i];
65        x3 = data[2][i];
66        x4 = data[3][i];
67        x5 = data[4][i];
68
69        f = 0.1 * Math.Exp(4 * x1) + 4 / (1 + Math.Exp(-20 * (x2 - 0.5))) + 3 * x3 + 2 * x4 + x5;
70
71        results.Add(f + NormalDistributedRandom.NextDouble(rand, 0, 1));
72      }
73      data.Add(results);
74
75      return data;
76    }
77  }
78}
Note: See TracBrowser for help on using the repository browser.