Changeset 8192 for trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Classification/CSV
- 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/CSV/ClassifiactionCSVInstanceProvider.cs
r8180 r8192 20 20 #endregion 21 21 22 23 22 using System; 24 23 using System.Collections.Generic; 25 24 using System.IO; 25 using System.Linq; 26 26 using System.Text; 27 27 using HeuristicLab.Problems.DataAnalysis; 28 28 29 namespace HeuristicLab.Problems.Instances.DataAnalysis { 29 30 public class ClassificationCSVInstanceProvider : ClassificationInstanceProvider { … … 43 44 } 44 45 45 public override bool CanSaveData {46 get { return true; }47 }48 49 46 public override IEnumerable<IDataDescriptor> GetDataDescriptors() { 50 47 return new List<IDataDescriptor>(); 51 48 } 52 49 53 public override void SaveData(IClassificationProblemData instance, string path) { 50 public override IClassificationProblemData LoadData(IDataDescriptor descriptor) { 51 throw new NotImplementedException(); 52 } 53 54 public override bool CanImportData { 55 get { return true; } 56 } 57 public override IClassificationProblemData ImportData(string path) { 58 TableFileParser csvFileParser = new TableFileParser(); 59 60 csvFileParser.Parse(path); 61 62 Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values); 63 string targetVar = csvFileParser.VariableNames.Where(x => dataset.DoubleVariables.Contains(x)).Last(); 64 IEnumerable<string> allowedInputVars = dataset.DoubleVariables.Where(x => !x.Equals(targetVar)); 65 66 ClassificationProblemData claData = new ClassificationProblemData(dataset, allowedInputVars, targetVar); 67 68 int trainingPartEnd = csvFileParser.Rows * 2 / 3; 69 claData.TrainingPartition.Start = 0; 70 claData.TrainingPartition.End = trainingPartEnd; 71 claData.TestPartition.Start = trainingPartEnd; 72 claData.TestPartition.End = csvFileParser.Rows; 73 int pos = path.LastIndexOf('\\'); 74 if (pos < 0) 75 claData.Name = path; 76 else { 77 pos++; 78 claData.Name = path.Substring(pos, path.Length - pos); 79 } 80 81 return claData; 82 } 83 84 public override bool CanExportData { 85 get { return true; } 86 } 87 public override void ExportData(IClassificationProblemData instance, string path) { 54 88 StringBuilder strBuilder = new StringBuilder(); 55 89 … … 74 108 } 75 109 } 76 77 public override IClassificationProblemData LoadData(IDataDescriptor descriptor) {78 throw new NotImplementedException();79 }80 110 } 81 111 }
Note: See TracChangeset
for help on using the changeset viewer.