- Timestamp:
- 05/21/12 11:13:32 (13 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3
-
Property
svn:ignore
set to
Plugin.cs
obj
-
Property
svn:ignore
set to
-
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/RegressionInstanceProvider.cs
r7849 r7851 23 23 using System.Collections; 24 24 using System.Collections.Generic; 25 using System.Globalization;26 25 using System.IO; 27 26 using System.Linq; … … 33 32 34 33 public IRegressionProblemData LoadData(string path) { 35 NumberFormatInfo numberFormat; 36 DateTimeFormatInfo dateFormat; 37 char separator; 38 TableFileParser.DetermineFileFormat(path, out numberFormat, out dateFormat, out separator); 34 TableFileParser csvFileParser = new TableFileParser(); 35 csvFileParser.Parse(path); 39 36 40 IRegressionProblemData regData = LoadData(new FileStream(path, FileMode.Open), numberFormat, dateFormat, separator); 37 Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values); 38 string targetVar = csvFileParser.VariableNames.Last(); 39 IEnumerable<string> allowedInputVars = csvFileParser.VariableNames.Where(x => !x.Equals(targetVar)); 40 41 IRegressionProblemData regData = new RegressionProblemData(dataset, allowedInputVars, targetVar); 42 43 int trainingPartEnd = csvFileParser.Rows * 2 / 3; 44 regData.TrainingPartition.Start = 0; 45 regData.TrainingPartition.End = trainingPartEnd; 46 regData.TestPartition.Start = trainingPartEnd; 47 regData.TestPartition.End = csvFileParser.Rows; 41 48 42 49 int pos = path.LastIndexOf('\\'); … … 47 54 regData.Name = path.Substring(pos, path.Length - pos); 48 55 } 49 return regData;50 }51 52 protected IRegressionProblemData LoadData(Stream stream, NumberFormatInfo numberFormat, DateTimeFormatInfo dateFormat, char separator) {53 TableFileParser csvFileParser = new TableFileParser();54 55 csvFileParser.Parse(stream, numberFormat, dateFormat, separator);56 57 Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);58 string targetVar = csvFileParser.VariableNames.Last();59 IEnumerable<string> allowedInputVars = csvFileParser.VariableNames.Where(x => !x.Equals(targetVar));60 61 RegressionProblemData regData = new RegressionProblemData(dataset, allowedInputVars, targetVar);62 63 int trainingPartEnd = csvFileParser.Rows * 2 / 3;64 regData.TrainingPartition.Start = 0;65 regData.TrainingPartition.End = trainingPartEnd;66 regData.TestPartition.Start = trainingPartEnd;67 regData.TestPartition.End = csvFileParser.Rows;68 69 56 return regData; 70 57 } -
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/ResourceRegressionInstanceProvider.cs
r7849 r7851 64 64 } 65 65 66 IRegressionProblemData regData;66 TableFileParser csvFileParser = new TableFileParser(); 67 67 using (Stream stream = instancesZipFile.GetInputStream(entry)) { 68 regData = LoadData(stream, numberFormat, dateFormat, separator);68 csvFileParser.Parse(stream, numberFormat, dateFormat, separator); 69 69 } 70 71 Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values); 72 string targetVar = csvFileParser.VariableNames.Last(); 73 IEnumerable<string> allowedInputVars = csvFileParser.VariableNames.Where(x => !x.Equals(targetVar)); 74 75 IRegressionProblemData regData = new RegressionProblemData(dataset, allowedInputVars, targetVar); 76 77 int trainingPartEnd = csvFileParser.Rows * 2 / 3; 78 regData.TrainingPartition.Start = 0; 79 regData.TrainingPartition.End = trainingPartEnd; 80 regData.TestPartition.Start = trainingPartEnd; 81 regData.TestPartition.End = csvFileParser.Rows; 70 82 71 83 regData.Name = descriptor.Name;
Note: See TracChangeset
for help on using the changeset viewer.