Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/17/11 14:37:34 (13 years ago)
Author:
mkommend
Message:

#1592: Enabled creation of empty ensemble solutions and problem data changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleSolution.cs

    r6613 r6666  
    3535  [StorableClass]
    3636  [Item("Classification Ensemble Solution", "A classification solution that contains an ensemble of multiple classification models")]
    37   // [Creatable("Data Analysis")]
     37  [Creatable("Data Analysis - Ensembles")]
    3838  public sealed class ClassificationEnsembleSolution : ClassificationSolution, IClassificationEnsembleSolution {
    3939    public new IClassificationEnsembleModel Model {
    4040      get { return (IClassificationEnsembleModel)base.Model; }
     41    }
     42    public new ClassificationEnsembleProblemData ProblemData {
     43      get { return (ClassificationEnsembleProblemData)base.ProblemData; }
     44      set { base.ProblemData = value; }
    4145    }
    4246
     
    8286
    8387      classificationSolutions = cloner.Clone(original.classificationSolutions);
     88      RegisterClassificationSolutionsEventHandler();
     89    }
     90
     91    public ClassificationEnsembleSolution()
     92      : base(new ClassificationEnsembleModel(), ClassificationEnsembleProblemData.EmptyProblemData) {
     93      trainingPartitions = new Dictionary<IClassificationModel, IntRange>();
     94      testPartitions = new Dictionary<IClassificationModel, IntRange>();
     95      classificationSolutions = new ItemCollection<IClassificationSolution>();
     96
    8497      RegisterClassificationSolutionsEventHandler();
    8598    }
     
    208221    #endregion
    209222
     223    protected override void OnProblemDataChanged() {
     224      IClassificationProblemData problemData = new ClassificationProblemData(ProblemData.Dataset,
     225                                                                     ProblemData.AllowedInputVariables,
     226                                                                     ProblemData.TargetVariable);
     227      problemData.TrainingPartition.Start = ProblemData.TrainingPartition.Start;
     228      problemData.TrainingPartition.End = ProblemData.TrainingPartition.End;
     229      problemData.TestPartition.Start = ProblemData.TestPartition.Start;
     230      problemData.TestPartition.End = ProblemData.TestPartition.End;
     231
     232      foreach (var solution in ClassificationSolutions) {
     233        if (solution is ClassificationEnsembleSolution)
     234          solution.ProblemData = ProblemData;
     235        else
     236          solution.ProblemData = problemData;
     237      }
     238      foreach (var trainingPartition in trainingPartitions.Values) {
     239        trainingPartition.Start = ProblemData.TrainingPartition.Start;
     240        trainingPartition.End = ProblemData.TrainingPartition.End;
     241      }
     242      foreach (var testPartition in testPartitions.Values) {
     243        testPartition.Start = ProblemData.TestPartition.Start;
     244        testPartition.End = ProblemData.TestPartition.End;
     245      }
     246
     247      base.OnProblemDataChanged();
     248    }
     249
    210250    public void AddClassificationSolutions(IEnumerable<IClassificationSolution> solutions) {
    211251      classificationSolutions.AddRange(solutions);
Note: See TracChangeset for help on using the changeset viewer.