[7860] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[14185] | 3 | * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[7860] | 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 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Linq;
|
---|
| 25 | using HeuristicLab.Random;
|
---|
| 26 |
|
---|
| 27 | namespace 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"; } }
|
---|
[8825] | 38 | protected override string[] VariableNames { get { return new string[] { "X1", "X2", "X3", "X4", "X5", "X6", "X7", "X8", "X9", "X10", "Y" }; } }
|
---|
[8672] | 39 | protected override string[] AllowedInputVariables { get { return new string[] { "X1", "X2", "X3", "X4", "X5", "X6", "X7", "X8", "X9", "X10" }; } }
|
---|
[7860] | 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 |
|
---|
[14228] | 45 | public int Seed { get; }
|
---|
[7860] | 46 |
|
---|
[14228] | 47 | public FriedmanTwo() : this((int)DateTime.Now.Ticks) { }
|
---|
| 48 |
|
---|
| 49 | public FriedmanTwo(int seed) : base() {
|
---|
| 50 | Seed = seed;
|
---|
| 51 | }
|
---|
[7860] | 52 | protected override List<List<double>> GenerateValues() {
|
---|
| 53 | List<List<double>> data = new List<List<double>>();
|
---|
[14228] | 54 | var rand = new MersenneTwister((uint)Seed);
|
---|
| 55 |
|
---|
[7860] | 56 | for (int i = 0; i < AllowedInputVariables.Count(); i++) {
|
---|
[14228] | 57 | data.Add(ValueGenerator.GenerateUniformDistributedValues(rand.Next(), 10000, 0, 1).ToList());
|
---|
[7860] | 58 | }
|
---|
| 59 |
|
---|
| 60 | double x1, x2, x3, x4, x5;
|
---|
| 61 | double f;
|
---|
| 62 | List<double> results = new List<double>();
|
---|
| 63 | for (int i = 0; i < data[0].Count; i++) {
|
---|
| 64 | x1 = data[0][i];
|
---|
| 65 | x2 = data[1][i];
|
---|
| 66 | x3 = data[2][i];
|
---|
| 67 | x4 = data[3][i];
|
---|
| 68 | x5 = data[4][i];
|
---|
| 69 |
|
---|
| 70 | f = 10 * Math.Sin(Math.PI * x1 * x2) + 20 * Math.Pow(x3 - 0.5, 2) + 10 * x4 + 5 * x5;
|
---|
| 71 |
|
---|
| 72 | results.Add(f + NormalDistributedRandom.NextDouble(rand, 0, 1));
|
---|
| 73 | }
|
---|
| 74 | data.Add(results);
|
---|
| 75 |
|
---|
| 76 | return data;
|
---|
| 77 | }
|
---|
| 78 | }
|
---|
| 79 | }
|
---|