- 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/Regression/CSV/RegressionCSVInstanceProvider.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 RegressionCSVInstanceProvider : RegressionInstanceProvider { … … 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 } 49 public override IRegressionProblemData LoadData(IDataDescriptor descriptor) { 50 throw new NotImplementedException(); 51 } 52 52 53 public override void SaveData(IRegressionProblemData instance, string path) { 53 public override bool CanImportData { 54 get { return true; } 55 } 56 public override IRegressionProblemData ImportData(string path) { 57 TableFileParser csvFileParser = new TableFileParser(); 58 csvFileParser.Parse(path); 59 60 Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values); 61 string targetVar = csvFileParser.VariableNames.Where(x => dataset.DoubleVariables.Contains(x)).Last(); 62 63 IEnumerable<string> allowedInputVars = dataset.DoubleVariables.Where(x => !x.Equals(targetVar)); 64 65 IRegressionProblemData regData = new RegressionProblemData(dataset, allowedInputVars, targetVar); 66 67 int trainingPartEnd = csvFileParser.Rows * 2 / 3; 68 regData.TrainingPartition.Start = 0; 69 regData.TrainingPartition.End = trainingPartEnd; 70 regData.TestPartition.Start = trainingPartEnd; 71 regData.TestPartition.End = csvFileParser.Rows; 72 73 int pos = path.LastIndexOf('\\'); 74 if (pos < 0) 75 regData.Name = path; 76 else { 77 pos++; 78 regData.Name = path.Substring(pos, path.Length - pos); 79 } 80 return regData; 81 } 82 83 public override bool CanExportData { 84 get { return true; } 85 } 86 public override void ExportData(IRegressionProblemData instance, string path) { 54 87 StringBuilder strBuilder = new StringBuilder(); 55 88 … … 74 107 } 75 108 } 76 77 public override IRegressionProblemData LoadData(IDataDescriptor descriptor) {78 throw new NotImplementedException();79 }80 109 } 81 110 }
Note: See TracChangeset
for help on using the changeset viewer.