Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/23/11 14:47:27 (14 years ago)
Author:
gkronber
Message:

#1450 added flattening of sub-results in ensemble solutions for classification and regression in the cross-validation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs

    r6239 r6250  
    404404          solutions.Value.Select(x => x.ProblemData.TestPartition));
    405405
    406         aggregatedResults.Add(new Result(solutions.Key, ensembleSolution));
    407       }
    408       return aggregatedResults;
     406        aggregatedResults.Add(new Result(solutions.Key + " (ensemble)", ensembleSolution));
     407      }
     408      List<IResult> flattenedResults = new List<IResult>();
     409      CollectResultsRecursively("", aggregatedResults, flattenedResults);
     410      return flattenedResults;
    409411    }
    410412
     
    421423        }
    422424      }
    423       List<IResult> aggregatedResults = new List<IResult>();
     425      var aggregatedResults = new List<IResult>();
    424426      foreach (KeyValuePair<string, List<IClassificationSolution>> solutions in resultSolutions) {
    425427        var problemDataClone = (IClassificationProblemData)Problem.ProblemData.Clone();
     
    430432          solutions.Value.Select(x => x.ProblemData.TestPartition));
    431433
    432         aggregatedResults.Add(new Result(solutions.Key, ensembleSolution));
    433       }
    434       return aggregatedResults;
     434        aggregatedResults.Add(new Result(solutions.Key + " (ensemble)", ensembleSolution));
     435      }
     436      List<IResult> flattenedResults = new List<IResult>();
     437      CollectResultsRecursively("", aggregatedResults, flattenedResults);
     438      return flattenedResults;
     439    }
     440
     441    private void CollectResultsRecursively(string path, IEnumerable<IResult> results, IList<IResult> flattenedResults) {
     442      foreach (IResult result in results) {
     443        flattenedResults.Add(new Result(path + result.Name, result.Value));
     444        ResultCollection childCollection = result.Value as ResultCollection;
     445        if (childCollection != null) {
     446          CollectResultsRecursively(path + result.Name + ".", childCollection, flattenedResults);
     447        }
     448      }
    435449    }
    436450
     
    457471      foreach (KeyValuePair<string, List<double>> resultValue in resultValues) {
    458472        doubleValue.Value = resultValue.Value.Average();
    459         aggregatedResults.Add(new Result(resultValue.Key, (IItem)doubleValue.Clone()));
     473        aggregatedResults.Add(new Result(resultValue.Key + " (average)", (IItem)doubleValue.Clone()));
    460474        doubleValue.Value = resultValue.Value.StandardDeviation();
    461         aggregatedResults.Add(new Result(resultValue.Key + " StdDev", (IItem)doubleValue.Clone()));
     475        aggregatedResults.Add(new Result(resultValue.Key + " (std.dev.)", (IItem)doubleValue.Clone()));
    462476      }
    463477      return aggregatedResults;
Note: See TracChangeset for help on using the changeset viewer.