- Timestamp:
- 07/03/12 16:46:35 (12 years ago)
- Location:
- branches/GP-MoveOperators
- Files:
-
- 7 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-MoveOperators
- Property svn:mergeinfo changed
/trunk/sources merged: 8084,8088-8090,8092-8100,8102-8113,8115,8117-8132,8134-8146,8148-8156,8158-8160,8163-8170,8173-8176,8178-8190,8192-8205
- Property svn:mergeinfo changed
-
branches/GP-MoveOperators/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Classification/CSV/ClassifiactionCSVInstanceProvider.cs
r7860 r8206 20 20 #endregion 21 21 22 23 22 using System; 24 23 using System.Collections.Generic; 24 using System.IO; 25 using System.Linq; 26 using System.Text; 25 27 using HeuristicLab.Problems.DataAnalysis; 28 26 29 namespace HeuristicLab.Problems.Instances.DataAnalysis { 27 30 public class ClassificationCSVInstanceProvider : ClassificationInstanceProvider { 28 31 public override string Name { 29 get { return "C SV Problem Provider"; }32 get { return "Comma-separated Values File"; } 30 33 } 31 34 public override string Description { … … 48 51 throw new NotImplementedException(); 49 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) { 88 StringBuilder strBuilder = new StringBuilder(); 89 90 foreach (var variable in instance.InputVariables) { 91 strBuilder.Append(variable + ";"); 92 } 93 strBuilder.Remove(strBuilder.Length - 1, 1); 94 strBuilder.AppendLine(); 95 96 Dataset dataset = instance.Dataset; 97 98 for (int i = 0; i < dataset.Rows; i++) { 99 for (int j = 0; j < dataset.Columns; j++) { 100 strBuilder.Append(dataset.GetValue(i, j) + ";"); 101 } 102 strBuilder.Remove(strBuilder.Length - 1, 1); 103 strBuilder.AppendLine(); 104 } 105 106 using (StreamWriter writer = new StreamWriter(path)) { 107 writer.Write(strBuilder); 108 } 109 } 50 110 } 51 111 } -
branches/GP-MoveOperators/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Classification/ClassificationInstanceProvider.cs
r7965 r8206 20 20 #endregion 21 21 22 using System;23 using System.Collections;24 using System.Collections.Generic;25 using System.IO;26 using System.Linq;27 using System.Text;28 22 using HeuristicLab.Problems.DataAnalysis; 29 23 30 24 namespace HeuristicLab.Problems.Instances.DataAnalysis { 31 public abstract class ClassificationInstanceProvider : IProblemInstanceProvider<IClassificationProblemData> { 32 public IClassificationProblemData LoadData(string path) { 33 TableFileParser csvFileParser = new TableFileParser(); 34 35 csvFileParser.Parse(path); 36 37 Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values); 38 string targetVar = csvFileParser.VariableNames.Where(x => dataset.DoubleVariables.Contains(x)).Last(); 39 IEnumerable<string> allowedInputVars = dataset.DoubleVariables.Where(x => !x.Equals(targetVar)); 40 41 ClassificationProblemData claData = new ClassificationProblemData(dataset, allowedInputVars, targetVar); 42 43 int trainingPartEnd = csvFileParser.Rows * 2 / 3; 44 claData.TrainingPartition.Start = 0; 45 claData.TrainingPartition.End = trainingPartEnd; 46 claData.TestPartition.Start = trainingPartEnd; 47 claData.TestPartition.End = csvFileParser.Rows; 48 int pos = path.LastIndexOf('\\'); 49 if (pos < 0) 50 claData.Name = path; 51 else { 52 pos++; 53 claData.Name = path.Substring(pos, path.Length - pos); 54 } 55 56 return claData; 57 } 58 59 public void SaveData(IClassificationProblemData instance, string path) { 60 StringBuilder strBuilder = new StringBuilder(); 61 62 foreach (var variable in instance.InputVariables) { 63 strBuilder.Append(variable + ";"); 64 } 65 strBuilder.Remove(strBuilder.Length - 1, 1); 66 strBuilder.AppendLine(); 67 68 Dataset dataset = instance.Dataset; 69 70 for (int i = 0; i < dataset.Rows; i++) { 71 for (int j = 0; j < dataset.Columns; j++) { 72 strBuilder.Append(dataset.GetValue(i, j) + ";"); 73 } 74 strBuilder.Remove(strBuilder.Length - 1, 1); 75 strBuilder.AppendLine(); 76 } 77 78 using (StreamWriter writer = new StreamWriter(path)) { 79 writer.Write(strBuilder); 80 } 81 } 82 83 public abstract IEnumerable<IDataDescriptor> GetDataDescriptors(); 84 public abstract IClassificationProblemData LoadData(IDataDescriptor descriptor); 85 86 public abstract string Name { get; } 87 public abstract string Description { get; } 88 public abstract Uri WebLink { get; } 89 public abstract string ReferencePublication { get; } 25 public abstract class ClassificationInstanceProvider : ProblemInstanceProvider<IClassificationProblemData> { 90 26 } 91 27 } -
branches/GP-MoveOperators/HeuristicLab.Problems.Instances.DataAnalysis/3.3/HeuristicLab.Problems.Instances.DataAnalysis-3.3.csproj
r7892 r8206 121 121 <Compile Include="Classification\ResourceClassificationDataDescriptor.cs" /> 122 122 <Compile Include="Classification\ResourceClassificationInstanceProvider.cs" /> 123 <Compile Include="Clustering\ClusteringInstanceProvider.cs" /> 124 <Compile Include="Clustering\CSV\ClusteringCSVInstanceProvider.cs" /> 123 125 <Compile Include="Plugin.cs" /> 124 126 <Compile Include="Properties\AssemblyInfo.cs" /> -
branches/GP-MoveOperators/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Plugin.cs.frame
r7849 r8206 25 25 [Plugin("HeuristicLab.Problems.Instances.DataAnalysis", "3.3.6.$WCREV$")] 26 26 [PluginFile("HeuristicLab.Problems.Instances.DataAnalysis-3.3.dll", PluginFileType.Assembly)] 27 [PluginDependency("HeuristicLab.Common", "3.3")]28 27 [PluginDependency("HeuristicLab.Core", "3.3")] 29 28 [PluginDependency("HeuristicLab.Data", "3.3")] -
branches/GP-MoveOperators/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/CSV/RegressionCSVInstanceProvider.cs
r7860 r8206 20 20 #endregion 21 21 22 23 22 using System; 24 23 using System.Collections.Generic; 24 using System.IO; 25 using System.Linq; 26 using System.Text; 25 27 using HeuristicLab.Problems.DataAnalysis; 28 26 29 namespace HeuristicLab.Problems.Instances.DataAnalysis { 27 30 public class RegressionCSVInstanceProvider : RegressionInstanceProvider { 28 31 public override string Name { 29 get { return "C SV Problem Provider"; }32 get { return "Comma-separated Values File"; } 30 33 } 31 34 public override string Description { … … 44 47 return new List<IDataDescriptor>(); 45 48 } 46 47 49 public override IRegressionProblemData LoadData(IDataDescriptor descriptor) { 48 50 throw new NotImplementedException(); 49 51 } 52 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) { 87 StringBuilder strBuilder = new StringBuilder(); 88 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) + ";"); 100 } 101 strBuilder.Remove(strBuilder.Length - 1, 1); 102 strBuilder.AppendLine(); 103 } 104 105 using (StreamWriter writer = new StreamWriter(path)) { 106 writer.Write(strBuilder); 107 } 108 } 50 109 } 51 110 } -
branches/GP-MoveOperators/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/RegressionInstanceProvider.cs
r7965 r8206 20 20 #endregion 21 21 22 using System;23 using System.Collections;24 using System.Collections.Generic;25 using System.IO;26 using System.Linq;27 using System.Text;28 22 using HeuristicLab.Problems.DataAnalysis; 29 23 30 24 namespace HeuristicLab.Problems.Instances.DataAnalysis { 31 public abstract class RegressionInstanceProvider : IProblemInstanceProvider<IRegressionProblemData> { 32 33 public IRegressionProblemData LoadData(string path) { 34 TableFileParser csvFileParser = new TableFileParser(); 35 csvFileParser.Parse(path); 36 37 Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values); 38 string targetVar = csvFileParser.VariableNames.Where(x => dataset.DoubleVariables.Contains(x)).Last(); 39 40 IEnumerable<string> allowedInputVars = dataset.DoubleVariables.Where(x => !x.Equals(targetVar)); 41 42 IRegressionProblemData regData = new RegressionProblemData(dataset, allowedInputVars, targetVar); 43 44 int trainingPartEnd = csvFileParser.Rows * 2 / 3; 45 regData.TrainingPartition.Start = 0; 46 regData.TrainingPartition.End = trainingPartEnd; 47 regData.TestPartition.Start = trainingPartEnd; 48 regData.TestPartition.End = csvFileParser.Rows; 49 50 int pos = path.LastIndexOf('\\'); 51 if (pos < 0) 52 regData.Name = path; 53 else { 54 pos++; 55 regData.Name = path.Substring(pos, path.Length - pos); 56 } 57 return regData; 58 } 59 60 public void SaveData(IRegressionProblemData instance, string path) { 61 StringBuilder strBuilder = new StringBuilder(); 62 63 foreach (var variable in instance.InputVariables) { 64 strBuilder.Append(variable + ";"); 65 } 66 strBuilder.Remove(strBuilder.Length - 1, 1); 67 strBuilder.AppendLine(); 68 69 Dataset dataset = instance.Dataset; 70 71 for (int i = 0; i < dataset.Rows; i++) { 72 for (int j = 0; j < dataset.Columns; j++) { 73 strBuilder.Append(dataset.GetValue(i, j) + ";"); 74 } 75 strBuilder.Remove(strBuilder.Length - 1, 1); 76 strBuilder.AppendLine(); 77 } 78 79 using (StreamWriter writer = new StreamWriter(path)) { 80 writer.Write(strBuilder); 81 } 82 } 83 84 public abstract IEnumerable<IDataDescriptor> GetDataDescriptors(); 85 public abstract IRegressionProblemData LoadData(IDataDescriptor descriptor); 86 87 public abstract string Name { get; } 88 public abstract string Description { get; } 89 public abstract Uri WebLink { get; } 90 public abstract string ReferencePublication { get; } 25 public abstract class RegressionInstanceProvider : ProblemInstanceProvider<IRegressionProblemData> { 91 26 } 92 27 }
Note: See TracChangeset
for help on using the changeset viewer.