Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/09/13 10:50:08 (12 years ago)
Author:
sforsten
Message:

#2001:

  • renamed RegressionRealWorldInstanceProvider to RealWorldRegressionInstanceProvider
  • added IRealWorldRegressionDataDescriptor and RealWorldResourceRegressionDataDescriptor to set the training and test partition for real world regression problem instances
  • shuffled housing dataset and renamed TowerData.txt to Tower.txt in RegressionRealWorld.zip
Location:
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/RealWorld
Files:
3 added
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/RealWorld/RealWorldRegressionInstanceProvider.cs

    r9129 r9131  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.IO;
     25using System.Linq;
     26using HeuristicLab.Problems.DataAnalysis;
     27using ICSharpCode.SharpZipLib.Zip;
    2328
    2429namespace HeuristicLab.Problems.Instances.DataAnalysis {
     
    4045
    4146    protected override string FileName { get { return "RegressionRealWorld"; } }
     47
     48    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
     49      List<IRealWorldRegressionDataDescriptor> descriptorList = new List<IRealWorldRegressionDataDescriptor>();
     50      descriptorList.Add(new Tower());
     51      var solutionsArchiveName = GetResourceName(FileName + @"\.zip");
     52      if (!String.IsNullOrEmpty(solutionsArchiveName)) {
     53        using (var solutionsZipFile = new ZipInputStream(GetType().Assembly.GetManifestResourceStream(solutionsArchiveName))) {
     54          IList<string> entries = new List<string>();
     55          ZipEntry curEntry;
     56          while ((curEntry = solutionsZipFile.GetNextEntry()) != null) {
     57            entries.Add(curEntry.Name);
     58          }
     59          foreach (var entry in entries.OrderBy(x => x)) {
     60            string prettyName = Path.GetFileNameWithoutExtension(entry);
     61            IRealWorldRegressionDataDescriptor desc = descriptorList.Where(x => x.Name.Equals(prettyName)).FirstOrDefault();
     62            if (desc != null) {
     63              yield return new RealWorldResourceRegressionDataDescriptor(prettyName, desc.Description, entry, desc.Training, desc.Test);
     64            } else
     65              yield return new ResourceRegressionDataDescriptor(prettyName, Description, entry);
     66          }
     67        }
     68      }
     69    }
     70
     71    public override IRegressionProblemData LoadData(IDataDescriptor id) {
     72      var problem = base.LoadData(id);
     73
     74      var descriptor = id as RealWorldResourceRegressionDataDescriptor;
     75
     76      if (descriptor == null) {
     77        return problem;
     78      }
     79
     80      problem.TrainingPartition.Start = descriptor.Training.Start;
     81      problem.TrainingPartition.End = descriptor.Training.End;
     82      problem.TestPartition.Start = descriptor.Test.Start;
     83      problem.TestPartition.End = descriptor.Test.End;
     84
     85      return problem;
     86    }
    4287  }
    4388}
Note: See TracChangeset for help on using the changeset viewer.