- Timestamp:
- 09/04/12 11:32:31 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/CSV/RegressionCSVInstanceProvider.cs
r8530 r8566 26 26 using System.Linq; 27 27 using System.Text; 28 using HeuristicLab.Common; 28 29 using HeuristicLab.Problems.DataAnalysis; 29 30 … … 60 61 61 62 Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values); 62 string targetVar = csvFileParser.VariableNames.Where(x => dataset.DoubleVariables.Contains(x)).Last();63 string targetVar = dataset.DoubleVariables.Last(); 63 64 64 IEnumerable<string> allowedInputVars = dataset.DoubleVariables.Where(x => !x.Equals(targetVar)); 65 // turn of input variables that are constant in the training partition 66 var allowedInputVars = new List<string>(); 67 var trainingIndizes = Enumerable.Range(0, (csvFileParser.Rows * 2) / 3); 68 foreach (var variableName in dataset.DoubleVariables) { 69 if (dataset.GetDoubleValues(variableName, trainingIndizes).Range() > 0 && 70 variableName != targetVar) 71 allowedInputVars.Add(variableName); 72 } 65 73 66 IRegressionProblemData reg Data = new RegressionProblemData(dataset, allowedInputVars, targetVar);74 IRegressionProblemData regressionData = new RegressionProblemData(dataset, allowedInputVars, targetVar); 67 75 68 int trainingPartEnd = csvFileParser.Rows * 2 / 3;69 reg Data.TrainingPartition.Start = 0;70 reg Data.TrainingPartition.End = trainingPartEnd;71 reg Data.TestPartition.Start = trainingPartEnd;72 reg Data.TestPartition.End = csvFileParser.Rows;76 var trainingPartEnd = trainingIndizes.Last(); 77 regressionData.TrainingPartition.Start = trainingIndizes.First(); 78 regressionData.TrainingPartition.End = trainingPartEnd; 79 regressionData.TestPartition.Start = trainingPartEnd; 80 regressionData.TestPartition.End = csvFileParser.Rows; 73 81 74 int pos = path.LastIndexOf('\\'); 75 if (pos < 0) 76 regData.Name = path; 77 else { 78 pos++; 79 regData.Name = path.Substring(pos, path.Length - pos); 80 } 81 return regData; 82 regressionData.Name = Path.GetFileName(path); 83 84 return regressionData; 82 85 } 83 86
Note: See TracChangeset
for help on using the changeset viewer.