Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10526 for trunk


Ignore:
Timestamp:
03/03/14 13:56:10 (11 years ago)
Author:
mkommend
Message:

#2160: Corrected create ensemble menu item to clone the selected data analysis solutions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/MenuItems/CreateEnsembleMenuItem.cs

    r9973 r10526  
    2323using System.Collections.Generic;
    2424using System.Linq;
    25 using System.Windows.Forms;
    26 using HeuristicLab.Core;
     25using HeuristicLab.Common;
    2726using HeuristicLab.MainForm;
    2827using HeuristicLab.MainForm.WindowsForms;
     
    6867        if (group.All(s => s is IRegressionSolution)) {
    6968          // show all regression ensembles
    70           // clone problemdata (N.B. this assumes all solutions are based on the same problem data!)
    71           var problemData = (RegressionProblemData)group
    72             .OfType<IRegressionSolution>()
    73             .First()
    74             .ProblemData.Clone();
     69          // N.B. this assumes all solutions are based on the same problem data!
     70          // the problem data is not cloned because the individual solutions were already cloned
     71          var problemData = group.OfType<IRegressionSolution>().First().ProblemData;
    7572          var ensemble = new RegressionEnsembleSolution(problemData);
    7673          ensemble.Name = group.Key + " ensemble";
     
    8178        } else if (group.All(s => s is IClassificationSolution)) {
    8279          // show all classification ensembles
    83           var problemData = (ClassificationProblemData)group
    84             .OfType<IClassificationSolution>()
    85             .First()
    86             .ProblemData.Clone();
     80          // N.B. this assumes all solutions are based on the same problem data!
     81          // the problem data is not cloned because the individual solutions were already cloned
     82          var problemData = (ClassificationProblemData)group.OfType<IClassificationSolution>().First().ProblemData;
    8783          var ensemble = new ClassificationEnsembleSolution(Enumerable.Empty<IClassificationModel>(), problemData);
    8884          ensemble.Name = group.Key + " ensemble";
     
    9591    }
    9692
    97     private IEnumerable<KeyValuePair<string, IItem>> GetDataAnalysisResults(IContentView view) {
    98       var empty = Enumerable.Empty<KeyValuePair<string, IItem>>();
     93    private IEnumerable<KeyValuePair<string, IDataAnalysisSolution>> GetDataAnalysisResults(IContentView view) {
     94      var empty = Enumerable.Empty<KeyValuePair<string, IDataAnalysisSolution>>();
    9995      if (view == null) return empty;
    10096      if (view.Content == null) return empty;
     
    114110    }
    115111
    116     private IEnumerable<KeyValuePair<string, IItem>> GetDataAnalysisResults(IEnumerable<IRun> runs) {
     112    private IEnumerable<KeyValuePair<string, IDataAnalysisSolution>> GetDataAnalysisResults(IEnumerable<IRun> runs) {
     113      var cloner = new Cloner();
    117114      var allResults = from r in runs
    118115                       select r.Results;
    119116      return from r in allResults
    120117             from result in r
    121              let s = result.Value as IDataAnalysisSolution
     118             let s = cloner.Clone(result.Value) as IDataAnalysisSolution
    122119             where s != null
    123              select result;
     120             select new KeyValuePair<string, IDataAnalysisSolution>(result.Key, s);
    124121    }
    125122  }
Note: See TracChangeset for help on using the changeset viewer.