- Timestamp:
- 04/16/13 13:13:41 (12 years ago)
- Location:
- branches/OaaS
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS
- Property svn:ignore
-
old new 21 21 protoc.exe 22 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll 23 24 packages
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/OaaS/HeuristicLab.Problems.Instances.DataAnalysis
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis merged eligible /branches/Algorithms.GradientDescent/HeuristicLab.Problems.Instances.DataAnalysis 5516-5520 /branches/Benchmarking/sources/HeuristicLab.Problems.Instances.DataAnalysis 6917-7005 /branches/CloningRefactoring/HeuristicLab.Problems.Instances.DataAnalysis 4656-4721 /branches/DataAnalysis Refactoring/HeuristicLab.Problems.Instances.DataAnalysis 5471-5808 /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Problems.Instances.DataAnalysis 5815-6180 /branches/DataAnalysis/HeuristicLab.Problems.Instances.DataAnalysis 4458-4459,4462,4464 /branches/DataAnalysisCSVImport/HeuristicLab.Problems.Instances.DataAnalysis 8695-8875 /branches/GP.Grammar.Editor/HeuristicLab.Problems.Instances.DataAnalysis 6284-6795 /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Problems.Instances.DataAnalysis 5060 /branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.Instances.DataAnalysis 7889-8789 /branches/NET40/sources/HeuristicLab.Problems.Instances.DataAnalysis 5138-5162 /branches/ParallelEngine/HeuristicLab.Problems.Instances.DataAnalysis 5175-5192 /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.DataAnalysis 7568-7810 /branches/QAPAlgorithms/HeuristicLab.Problems.Instances.DataAnalysis 6350-6627 /branches/Restructure trunk solution/HeuristicLab.Problems.Instances.DataAnalysis 6828 /branches/RuntimeOptimizer/HeuristicLab.Problems.Instances.DataAnalysis 8943-9078 /branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.Instances.DataAnalysis 7787-8333 /branches/SlaveShutdown/HeuristicLab.Problems.Instances.DataAnalysis 8944-8956 /branches/SuccessProgressAnalysis/HeuristicLab.Problems.Instances.DataAnalysis 5370-5682 /branches/Trunk/HeuristicLab.Problems.Instances.DataAnalysis 6829-6865 /branches/UnloadJobs/HeuristicLab.Problems.Instances.DataAnalysis 9168-9215 /branches/VNS/HeuristicLab.Problems.Instances.DataAnalysis 5594-5752 /branches/histogram/HeuristicLab.Problems.Instances.DataAnalysis 5959-6341
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/OaaS/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/CSV/RegressionCSVInstanceProvider.cs
r8211 r9363 21 21 22 22 using System; 23 using System.Collections; 23 24 using System.Collections.Generic; 24 25 using System.IO; 25 26 using System.Linq; 26 using System.Text;27 using HeuristicLab.Common; 27 28 using HeuristicLab.Problems.DataAnalysis; 28 29 … … 59 60 60 61 Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values); 61 string targetVar = csvFileParser.VariableNames.Where(x => dataset.DoubleVariables.Contains(x)).Last();62 string targetVar = dataset.DoubleVariables.Last(); 62 63 63 IEnumerable<string> allowedInputVars = dataset.DoubleVariables.Where(x => !x.Equals(targetVar)); 64 // turn of input variables that are constant in the training partition 65 var allowedInputVars = new List<string>(); 66 var trainingIndizes = Enumerable.Range(0, (csvFileParser.Rows * 2) / 3); 67 if (trainingIndizes.Count() >= 2) { 68 foreach (var variableName in dataset.DoubleVariables) { 69 if (dataset.GetDoubleValues(variableName, trainingIndizes).Range() > 0 && 70 variableName != targetVar) 71 allowedInputVars.Add(variableName); 72 } 73 } else { 74 allowedInputVars.AddRange(dataset.DoubleVariables.Where(x => !x.Equals(targetVar))); 75 } 64 76 65 IRegressionProblemData reg Data = new RegressionProblemData(dataset, allowedInputVars, targetVar);77 IRegressionProblemData regressionData = new RegressionProblemData(dataset, allowedInputVars, targetVar); 66 78 67 int trainingPartEnd = csvFileParser.Rows * 2 / 3;68 reg Data.TrainingPartition.Start = 0;69 reg Data.TrainingPartition.End = trainingPartEnd;70 reg Data.TestPartition.Start = trainingPartEnd;71 reg Data.TestPartition.End = csvFileParser.Rows;79 var trainingPartEnd = trainingIndizes.Last(); 80 regressionData.TrainingPartition.Start = trainingIndizes.First(); 81 regressionData.TrainingPartition.End = trainingPartEnd; 82 regressionData.TestPartition.Start = trainingPartEnd; 83 regressionData.TestPartition.End = csvFileParser.Rows; 72 84 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; 85 regressionData.Name = Path.GetFileName(path); 86 87 return regressionData; 81 88 } 82 89 83 public override bool CanExportData { 84 get { return true; } 85 } 86 public override void ExportData(IRegressionProblemData instance, string path) { 87 StringBuilder strBuilder = new StringBuilder(); 90 protected override IRegressionProblemData ImportData(string path, RegressionImportType type, TableFileParser csvFileParser) { 91 List<IList> values = csvFileParser.Values; 92 if (type.Shuffle) { 93 values = Shuffle(values); 94 } 95 Dataset dataset = new Dataset(csvFileParser.VariableNames, values); 88 96 89 foreach (var variable in instance.InputVariables) { 90 strBuilder.Append(variable + ";"); 91 } 92 strBuilder.Remove(strBuilder.Length - 1, 1); 93 strBuilder.AppendLine(); 94 95 Dataset dataset = instance.Dataset; 96 97 for (int i = 0; i < dataset.Rows; i++) { 98 for (int j = 0; j < dataset.Columns; j++) { 99 strBuilder.Append(dataset.GetValue(i, j) + ";"); 97 // turn of input variables that are constant in the training partition 98 var allowedInputVars = new List<string>(); 99 int trainingPartEnd = (csvFileParser.Rows * type.TrainingPercentage) / 100; 100 trainingPartEnd = trainingPartEnd > 0 ? trainingPartEnd : 1; 101 var trainingIndizes = Enumerable.Range(0, trainingPartEnd); 102 if (trainingIndizes.Count() >= 2) { 103 foreach (var variableName in dataset.DoubleVariables) { 104 if (dataset.GetDoubleValues(variableName, trainingIndizes).Range() > 0 && 105 variableName != type.TargetVariable) 106 allowedInputVars.Add(variableName); 100 107 } 101 strBuilder.Remove(strBuilder.Length - 1, 1);102 strBuilder.AppendLine();108 } else { 109 allowedInputVars.AddRange(dataset.DoubleVariables.Where(x => !x.Equals(type.TargetVariable))); 103 110 } 104 111 105 using (StreamWriter writer = new StreamWriter(path)) { 106 writer.Write(strBuilder); 107 } 112 RegressionProblemData regressionData = new RegressionProblemData(dataset, allowedInputVars, type.TargetVariable); 113 114 regressionData.TrainingPartition.Start = 0; 115 regressionData.TrainingPartition.End = trainingPartEnd; 116 regressionData.TestPartition.Start = trainingPartEnd; 117 regressionData.TestPartition.End = csvFileParser.Rows; 118 119 regressionData.Name = Path.GetFileName(path); 120 121 return regressionData; 108 122 } 109 123 }
Note: See TracChangeset
for help on using the changeset viewer.