Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Clustering/ClusteringProblemData.cs @ 7603

Last change on this file since 7603 was 7603, checked in by sforsten, 13 years ago

#1784:

  • first implementation of regression problem instances with one instance to test
File size: 4.2 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.Collections.Generic;
23using System.IO;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27using HeuristicLab.Problems.Instances;
28
29namespace HeuristicLab.Problems.DataAnalysis {
30  [StorableClass]
31  [Item("ClusteringProblemData", "Represents an item containing all data defining a clustering problem.")]
32  public sealed class ClusteringProblemData : DataAnalysisProblemData, IClusteringProblemData, IStorableContent {
33    public string Filename { get; set; }
34
35    #region default data
36    private static double[,] kozaF1 = new double[,] {
37          {2.017885919, -1.449165046},
38          {1.30060506,  -1.344523885},
39          {1.147134798, -1.317989331},
40          {0.877182504, -1.266142284},
41          {0.852562452, -1.261020794},
42          {0.431095788, -1.158793317},
43          {0.112586002, -1.050908405},
44          {0.04594507,  -1.021989402},
45          {0.042572879, -1.020438113},
46          {-0.074027291,  -0.959859562},
47          {-0.109178553,  -0.938094706},
48          {-0.259721109,  -0.803635355},
49          {-0.272991057,  -0.387519561},
50          {-0.161978191,  -0.193611001},
51          {-0.102489983,  -0.114215349},
52          {-0.01469968, -0.014918985},
53          {-0.008863365,  -0.008942626},
54          {0.026751057, 0.026054094},
55          {0.166922436, 0.14309643},
56          {0.176953808, 0.1504144},
57          {0.190233418, 0.159916534},
58          {0.199800708, 0.166635331},
59          {0.261502822, 0.207600348},
60          {0.30182879,  0.232370249},
61          {0.83763905,  0.468046718}
62    };
63    private static Dataset defaultDataset;
64    private static IEnumerable<string> defaultAllowedInputVariables;
65
66    static ClusteringProblemData() {
67      defaultDataset = new Dataset(new string[] { "y", "x" }, kozaF1);
68      defaultDataset.Name = "Fourth-order Polynomial Function Benchmark Dataset";
69      defaultDataset.Description = "f(x) = x^4 + x^3 + x^2 + x^1";
70      defaultAllowedInputVariables = new List<string>() { "x", "y" };
71    }
72    #endregion
73
74    [StorableConstructor]
75    private ClusteringProblemData(bool deserializing) : base(deserializing) { }
76    [StorableHook(HookType.AfterDeserialization)]
77    private void AfterDeserialization() {
78    }
79
80
81    private ClusteringProblemData(ClusteringProblemData original, Cloner cloner)
82      : base(original, cloner) {
83    }
84    public override IDeepCloneable Clone(Cloner cloner) { return new ClusteringProblemData(this, cloner); }
85
86    public ClusteringProblemData()
87      : this(defaultDataset, defaultAllowedInputVariables) {
88    }
89
90    public ClusteringProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables)
91      : base(dataset, allowedInputVariables) {
92    }
93
94
95    #region Import from file
96    public static ClusteringProblemData ImportFromFile(string fileName) {
97      TableFileParser csvFileParser = new TableFileParser();
98      csvFileParser.Parse(fileName);
99
100      Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
101      dataset.Name = Path.GetFileName(fileName);
102
103      ClusteringProblemData problemData = new ClusteringProblemData(dataset, dataset.DoubleVariables);
104      problemData.Name = "Data imported from " + Path.GetFileName(fileName);
105      return problemData;
106    }
107    #endregion
108  }
109}
Note: See TracBrowser for help on using the repository browser.