Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15094


Ignore:
Timestamp:
06/29/17 16:07:16 (7 years ago)
Author:
mkommend
Message:

#2779: Implemented necessary methods in the Dataset and ResidualAnalysisView to handle dates correctly.

Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualAnalysisView.cs

    r15088 r15094  
    9191      var doubleVars = ds.DoubleVariables.Where(vn => ds.GetDoubleValues(vn).Max() > ds.GetDoubleValues(vn).Min()).ToArray();
    9292      var stringVars = ds.StringVariables.Where(vn => ds.GetStringValues(vn).Distinct().Skip(1).Any()).ToArray();
     93      var dateTimeVars = ds.DateTimeVariables.Where(vn => ds.GetDateTimeValues(vn).Distinct().Skip(1).Any()).ToArray();
    9394
    9495      // produce training and test values separately as they might overlap (e.g. for ensembles)
     
    9697      int j = 0; // idx for predictedValues array
    9798      foreach (var i in problemData.TrainingIndices) {
    98         var run = CreateRunForIdx(i, problemData, doubleVars, stringVars);
     99        var run = CreateRunForIdx(i, problemData, doubleVars, stringVars, dateTimeVars);
    99100        var targetValue = ds.GetDoubleValue(problemData.TargetVariable, i);
    100101        AddErrors(run, predictedValuesTrain[j++], targetValue);
     
    106107      j = 0;
    107108      foreach (var i in problemData.TestIndices) {
    108         var run = CreateRunForIdx(i, problemData, doubleVars, stringVars);
     109        var run = CreateRunForIdx(i, problemData, doubleVars, stringVars, dateTimeVars);
    109110        var targetValue = ds.GetDoubleValue(problemData.TargetVariable, i);
    110111        AddErrors(run, predictedValuesTest[j++], targetValue);
     
    134135    }
    135136
    136     private IRun CreateRunForIdx(int i, IRegressionProblemData problemData, IEnumerable<string> doubleVars, IEnumerable<string> stringVars) {
     137    private IRun CreateRunForIdx(int i, IRegressionProblemData problemData, IEnumerable<string> doubleVars, IEnumerable<string> stringVars, IEnumerable<string> dateTimeVars) {
    137138      var ds = problemData.Dataset;
    138139      var run = new Run();
     
    143144        run.Results.Add(variableName, new StringValue(ds.GetStringValue(variableName, i)));
    144145      }
     146      foreach (var variableName in dateTimeVars) {
     147        run.Results.Add(variableName, new DateTimeValue(ds.GetDateTimeValue(variableName, i)));
     148      }
    145149      return run;
    146150    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Dataset.cs

    r15015 r15094  
    181181    }
    182182
     183    public IEnumerable<string> DateTimeVariables {
     184      get { return variableValues.Where(p => p.Value is IList<DateTime>).Select(p => p.Key); }
     185    }
     186
    183187    public IEnumerable<double> GetDoubleValues(string variableName) {
    184188      return GetValues<double>(variableName);
     
    215219      return new ReadOnlyCollection<string>(values);
    216220    }
     221
     222    public DateTime GetDateTimeValue(string variableName, int row) {
     223      var values = GetValues<DateTime>(variableName);
     224      return values[row];
     225    }
     226    public IEnumerable<DateTime> GetDateTimeValues(string variableName, IEnumerable<int> rows) {
     227      return GetValues<DateTime>(variableName, rows);
     228    }
     229    public ReadOnlyCollection<DateTime> GetReadOnlyDateTimeValues(string variableName) {
     230      var values = GetValues<DateTime>(variableName);
     231      return new ReadOnlyCollection<DateTime>(values);
     232    }
     233
    217234
    218235    private IEnumerable<T> GetValues<T>(string variableName, IEnumerable<int> rows) {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataset.cs

    r14826 r15094  
    3131    IEnumerable<string> DoubleVariables { get; }
    3232    IEnumerable<string> StringVariables { get; }
     33    IEnumerable<string> DateTimeVariables { get; }
    3334
    3435    bool VariableHasType<T>(string variableName);
     
    4445    ReadOnlyCollection<string> GetReadOnlyStringValues(string VariableName);
    4546
     47    System.DateTime GetDateTimeValue(string variableName, int row);
    4648    IEnumerable<DateTime> GetDateTimeValues(string variableName);
     49    IEnumerable<DateTime> GetDateTimeValues(string variableName, IEnumerable<int> rows);
     50    ReadOnlyCollection<DateTime> GetReadOnlyDateTimeValues(string variableName);
    4751  }
    4852}
Note: See TracChangeset for help on using the changeset viewer.