Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/14/11 16:45:46 (13 years ago)
Author:
abeham
Message:

#1465

  • updated branch with latest version of trunk
Location:
branches/histogram
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/histogram

  • branches/histogram/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs

    r5886 r6195  
    373373      foreach (IResult result in ExtractAndAggregateResults<PercentValue>(resultCollections))
    374374        results.Add(result.Name, result.Value);
    375 
     375      foreach (IResult result in ExtractAndAggregateRegressionSolutions(resultCollections)) {
     376        results.Add(result.Name, result.Value);
     377      }
    376378      results.Add("Execution Time", new TimeSpanValue(this.ExecutionTime));
    377379      results.Add("CrossValidation Folds", new RunCollection(runs));
     380    }
     381
     382    private IEnumerable<IResult> ExtractAndAggregateRegressionSolutions(IEnumerable<KeyValuePair<string, IItem>> resultCollections) {
     383      Dictionary<string, List<IRegressionSolution>> resultSolutions = new Dictionary<string, List<IRegressionSolution>>();
     384      foreach (var result in resultCollections) {
     385        var regressionSolution = result.Value as IRegressionSolution;
     386        if (regressionSolution != null) {
     387          if (resultSolutions.ContainsKey(result.Key)) {
     388            resultSolutions[result.Key].Add(regressionSolution);
     389          } else {
     390            resultSolutions.Add(result.Key, new List<IRegressionSolution>() { regressionSolution });
     391          }
     392        }
     393      }
     394      List<IResult> aggregatedResults = new List<IResult>();
     395      foreach (KeyValuePair<string, List<IRegressionSolution>> solutions in resultSolutions) {
     396        var problemDataClone = (IRegressionProblemData)Problem.ProblemData.Clone();
     397        problemDataClone.TrainingPartition.Start = SamplesStart.Value; problemDataClone.TrainingPartition.End = SamplesEnd.Value;
     398        problemDataClone.TestPartition.Start = SamplesStart.Value; problemDataClone.TestPartition.End = SamplesEnd.Value;
     399        var ensembleSolution = new RegressionEnsembleSolution(solutions.Value.Select(x => x.Model), problemDataClone,
     400          solutions.Value.Select(x => x.ProblemData.TrainingPartition),
     401          solutions.Value.Select(x => x.ProblemData.TestPartition));
     402
     403        aggregatedResults.Add(new Result(solutions.Key, ensembleSolution));
     404      }
     405      return aggregatedResults;
    378406    }
    379407
Note: See TracChangeset for help on using the changeset viewer.