Changeset 8598 for trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Classification/CSV
- 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/Classification/CSV/ClassifiactionCSVInstanceProvider.cs
r8566 r8598 21 21 22 22 using System; 23 using System.Collections; 23 24 using System.Collections.Generic; 24 25 using System.Globalization; … … 87 88 } 88 89 90 public override IClassificationProblemData ImportData(string path, DataAnalysisImportType type) { 91 TableFileParser csvFileParser = new TableFileParser(); 92 csvFileParser.Parse(path); 93 94 List<IList> values = csvFileParser.Values; 95 if (type.Shuffle) { 96 values = Shuffle(values); 97 } 98 99 Dataset dataset = new Dataset(csvFileParser.VariableNames, values); 100 string targetVar = dataset.DoubleVariables.Last(); 101 102 // turn of input variables that are constant in the training partition 103 var allowedInputVars = new List<string>(); 104 var trainingIndizes = Enumerable.Range(0, (csvFileParser.Rows * 2) / 3); 105 foreach (var variableName in dataset.DoubleVariables) { 106 if (dataset.GetDoubleValues(variableName, trainingIndizes).Range() > 0 && 107 variableName != targetVar) 108 allowedInputVars.Add(variableName); 109 } 110 111 ClassificationProblemData classificationData = new ClassificationProblemData(dataset, allowedInputVars, targetVar); 112 113 int trainingPartEnd = trainingIndizes.Last(); 114 classificationData.TrainingPartition.Start = trainingIndizes.First(); 115 classificationData.TrainingPartition.End = trainingPartEnd; 116 classificationData.TestPartition.Start = trainingPartEnd; 117 classificationData.TestPartition.End = csvFileParser.Rows; 118 119 classificationData.Name = Path.GetFileName(path); 120 121 return classificationData; 122 } 123 89 124 public override bool CanExportData { 90 125 get { return true; }
Note: See TracChangeset
for help on using the changeset viewer.