Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/03/12 13:41:36 (12 years ago)
Author:
sforsten
Message:

#1782:

  • renamed CanSave to CanExportData and SaveData to ExportData
  • added the same functionality for importing problem instance as we implemented for exporting
  • some special changes had to be made in Problems.Instances.VehicleRouting
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Classification/ClassificationInstanceProvider.cs

    r8180 r8192  
    2020#endregion
    2121
    22 using System.Collections;
    23 using System.Collections.Generic;
    24 using System.Linq;
    2522using HeuristicLab.Problems.DataAnalysis;
    2623
    2724namespace HeuristicLab.Problems.Instances.DataAnalysis {
    2825  public abstract class ClassificationInstanceProvider : ProblemInstanceProvider<IClassificationProblemData> {
    29     public override IClassificationProblemData LoadData(string path) {
    30       TableFileParser csvFileParser = new TableFileParser();
    31 
    32       csvFileParser.Parse(path);
    33 
    34       Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
    35       string targetVar = csvFileParser.VariableNames.Where(x => dataset.DoubleVariables.Contains(x)).Last();
    36       IEnumerable<string> allowedInputVars = dataset.DoubleVariables.Where(x => !x.Equals(targetVar));
    37 
    38       ClassificationProblemData claData = new ClassificationProblemData(dataset, allowedInputVars, targetVar);
    39 
    40       int trainingPartEnd = csvFileParser.Rows * 2 / 3;
    41       claData.TrainingPartition.Start = 0;
    42       claData.TrainingPartition.End = trainingPartEnd;
    43       claData.TestPartition.Start = trainingPartEnd;
    44       claData.TestPartition.End = csvFileParser.Rows;
    45       int pos = path.LastIndexOf('\\');
    46       if (pos < 0)
    47         claData.Name = path;
    48       else {
    49         pos++;
    50         claData.Name = path.Substring(pos, path.Length - pos);
    51       }
    52 
    53       return claData;
    54     }
    5526  }
    5627}
Note: See TracChangeset for help on using the changeset viewer.