- Timestamp:
- 09/07/12 14:53:39 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Clustering/CSV/ClusteringCSVInstanceProvider.cs
r8566 r8598 21 21 22 22 using System; 23 using System.Collections; 23 24 using System.Collections.Generic; 24 25 using System.Globalization; … … 59 60 public override IClusteringProblemData ImportData(string path) { 60 61 var csvFileParser = new TableFileParser(); 61 62 62 csvFileParser.Parse(path); 63 63 64 var dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values); 64 Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values); 65 string targetVar = dataset.DoubleVariables.Last(); 65 66 66 67 // turn of input variables that are constant in the training partition … … 68 69 var trainingIndizes = Enumerable.Range(0, (csvFileParser.Rows * 2) / 3); 69 70 foreach (var variableName in dataset.DoubleVariables) { 70 if (dataset.GetDoubleValues(variableName, trainingIndizes).Range() > 0) 71 if (dataset.GetDoubleValues(variableName, trainingIndizes).Range() > 0 && 72 variableName != targetVar) 71 73 allowedInputVars.Add(variableName); 72 74 } 73 75 74 var clusteringData = new ClusteringProblemData(dataset, allowedInputVars); 76 ClusteringProblemData clusteringData = new ClusteringProblemData(dataset, allowedInputVars); 77 78 int trainingPartEnd = trainingIndizes.Last(); 79 clusteringData.TrainingPartition.Start = trainingIndizes.First(); 80 clusteringData.TrainingPartition.End = trainingPartEnd; 81 clusteringData.TestPartition.Start = trainingPartEnd; 82 clusteringData.TestPartition.End = csvFileParser.Rows; 83 84 clusteringData.Name = Path.GetFileName(path); 85 86 return clusteringData; 87 } 88 89 public override IClusteringProblemData ImportData(string path, DataAnalysisImportType type) { 90 TableFileParser csvFileParser = new TableFileParser(); 91 csvFileParser.Parse(path); 92 93 List<IList> values = csvFileParser.Values; 94 if (type.Shuffle) { 95 values = Shuffle(values); 96 } 97 98 Dataset dataset = new Dataset(csvFileParser.VariableNames, values); 99 string targetVar = dataset.DoubleVariables.Last(); 100 101 // turn of input variables that are constant in the training partition 102 var allowedInputVars = new List<string>(); 103 var trainingIndizes = Enumerable.Range(0, (csvFileParser.Rows * 2) / 3); 104 foreach (var variableName in dataset.DoubleVariables) { 105 if (dataset.GetDoubleValues(variableName, trainingIndizes).Range() > 0 && 106 variableName != targetVar) 107 allowedInputVars.Add(variableName); 108 } 109 110 ClusteringProblemData clusteringData = new ClusteringProblemData(dataset, allowedInputVars); 75 111 76 112 int trainingPartEnd = trainingIndizes.Last();
Note: See TracChangeset
for help on using the changeset viewer.