Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/FeatureSelection/FeatureSelectionInstanceProvider.cs @ 13890

Last change on this file since 13890 was 12012, checked in by ascheibe, 10 years ago

#2212 merged r12008, r12009, r12010 back into trunk

File size: 3.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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.Data;
26using HeuristicLab.Problems.DataAnalysis;
27using HeuristicLab.Random;
28
29namespace HeuristicLab.Problems.Instances.DataAnalysis {
30  public class FeatureSelectionInstanceProvider : ArtificialRegressionInstanceProvider {
31    public override string Name {
32      get { return "Feature Selection Problems"; }
33    }
34    public override string Description {
35      get { return "A set of artificial feature selection benchmark problems"; }
36    }
37    public override Uri WebLink {
38      get { return new Uri("http://dev.heuristiclab.com"); }
39    }
40    public override string ReferencePublication {
41      get { return ""; }
42    }
43
44    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
45      var sizes = new int[] { 50, 100, 200 };
46      var pp = new double[] { 0.1, 0.25, 0.5 };
47      var noiseRatios = new double[] { 0.01, 0.05, 0.1, 0.2 };
48      var mt = new MersenneTwister();
49      var xGenerator = new NormalDistributedRandom(mt, 0, 1);
50      var weightGenerator = new UniformDistributedRandom(mt, 0, 10);
51      return (from size in sizes
52              from p in pp
53              from noiseRatio in noiseRatios
54              select new FeatureSelection(size, p, noiseRatio, xGenerator, weightGenerator))
55              .Cast<IDataDescriptor>()
56              .ToList();
57    }
58
59    public override IRegressionProblemData LoadData(IDataDescriptor descriptor) {
60      var featureSelectionDescriptor = descriptor as FeatureSelection;
61      if (featureSelectionDescriptor == null) throw new ArgumentException("FeatureSelectionInstanceProvider expects an FeatureSelection data descriptor.");
62      // base call generates a regression problem data
63      var regProblemData = base.LoadData(featureSelectionDescriptor);
64      var problemData =
65        new FeatureSelectionRegressionProblemData(
66          regProblemData.Dataset, regProblemData.AllowedInputVariables, regProblemData.TargetVariable,
67          featureSelectionDescriptor.SelectedFeatures, featureSelectionDescriptor.Weights,
68          featureSelectionDescriptor.OptimalRSquared);
69
70      // copy values from regProblemData to feature selection problem data
71      problemData.Name = regProblemData.Name;
72      problemData.Description = regProblemData.Description;
73      problemData.TrainingPartition.Start = regProblemData.TrainingPartition.Start;
74      problemData.TrainingPartition.End = regProblemData.TrainingPartition.End;
75      problemData.TestPartition.Start = regProblemData.TestPartition.Start;
76      problemData.TestPartition.End = regProblemData.TestPartition.End;
77
78      return problemData;
79    }
80  }
81}
Note: See TracBrowser for help on using the repository browser.