Changeset 8192 for trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Classification/ClassificationInstanceProvider.cs
- Timestamp:
- 07/03/12 13:41:36 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Classification/ClassificationInstanceProvider.cs
r8180 r8192 20 20 #endregion 21 21 22 using System.Collections;23 using System.Collections.Generic;24 using System.Linq;25 22 using HeuristicLab.Problems.DataAnalysis; 26 23 27 24 namespace HeuristicLab.Problems.Instances.DataAnalysis { 28 25 public abstract class ClassificationInstanceProvider : ProblemInstanceProvider<IClassificationProblemData> { 29 public override IClassificationProblemData LoadData(string path) {30 TableFileParser csvFileParser = new TableFileParser();31 32 csvFileParser.Parse(path);33 34 Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);35 string targetVar = csvFileParser.VariableNames.Where(x => dataset.DoubleVariables.Contains(x)).Last();36 IEnumerable<string> allowedInputVars = dataset.DoubleVariables.Where(x => !x.Equals(targetVar));37 38 ClassificationProblemData claData = new ClassificationProblemData(dataset, allowedInputVars, targetVar);39 40 int trainingPartEnd = csvFileParser.Rows * 2 / 3;41 claData.TrainingPartition.Start = 0;42 claData.TrainingPartition.End = trainingPartEnd;43 claData.TestPartition.Start = trainingPartEnd;44 claData.TestPartition.End = csvFileParser.Rows;45 int pos = path.LastIndexOf('\\');46 if (pos < 0)47 claData.Name = path;48 else {49 pos++;50 claData.Name = path.Substring(pos, path.Length - pos);51 }52 53 return claData;54 }55 26 } 56 27 }
Note: See TracChangeset
for help on using the changeset viewer.