Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/12/12 11:21:37 (13 years ago)
Author:
sforsten
Message:

#1776:

  • added before deleted code to restore some functionality (training and test partition of a model a stored in the .hl file again)
  • project files have been set to release
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleSolution.cs

    r7562 r7596  
    5252
    5353    private IClassificationEnsembleSolutionWeightCalculator weightCalculator;
    54 
    5554    public IClassificationEnsembleSolutionWeightCalculator WeightCalculator {
    5655      set {
     
    6463    }
    6564
     65    [Storable]
     66    private Dictionary<IClassificationModel, IntRange> trainingPartitions;
     67    [Storable]
     68    private Dictionary<IClassificationModel, IntRange> testPartitions;
     69
    6670    [StorableConstructor]
    6771    private ClassificationEnsembleSolution(bool deserializing)
     
    7377      foreach (var model in Model.Models) {
    7478        IClassificationProblemData problemData = (IClassificationProblemData)ProblemData.Clone();
     79        problemData.TrainingPartition.Start = trainingPartitions[model].Start;
     80        problemData.TrainingPartition.End = trainingPartitions[model].End;
     81        problemData.TestPartition.Start = testPartitions[model].Start;
     82        problemData.TestPartition.End = testPartitions[model].End;
     83
    7584        classificationSolutions.Add(model.CreateClassificationSolution(problemData));
    7685      }
     
    8089    private ClassificationEnsembleSolution(ClassificationEnsembleSolution original, Cloner cloner)
    8190      : base(original, cloner) {
     91      trainingPartitions = new Dictionary<IClassificationModel, IntRange>();
     92      testPartitions = new Dictionary<IClassificationModel, IntRange>();
     93      foreach (var pair in original.trainingPartitions) {
     94        trainingPartitions[cloner.Clone(pair.Key)] = cloner.Clone(pair.Value);
     95      }
     96      foreach (var pair in original.testPartitions) {
     97        testPartitions[cloner.Clone(pair.Key)] = cloner.Clone(pair.Value);
     98      }
     99
     100      weightCalculator = cloner.Clone(original.weightCalculator);
    82101      classificationSolutions = cloner.Clone(original.classificationSolutions);
    83102      RegisterClassificationSolutionsEventHandler();
     
    86105    public ClassificationEnsembleSolution()
    87106      : base(new ClassificationEnsembleModel(), ClassificationEnsembleProblemData.EmptyProblemData) {
     107      trainingPartitions = new Dictionary<IClassificationModel, IntRange>();
     108      testPartitions = new Dictionary<IClassificationModel, IntRange>();
    88109      classificationSolutions = new CheckedItemCollection<IClassificationSolution>();
    89 
    90110      weightCalculator = new MajorityVoteWeightCalculator();
    91111
     
    101121    public ClassificationEnsembleSolution(IEnumerable<IClassificationModel> models, IClassificationProblemData problemData, IEnumerable<IntRange> trainingPartitions, IEnumerable<IntRange> testPartitions)
    102122      : base(new ClassificationEnsembleModel(Enumerable.Empty<IClassificationModel>()), new ClassificationEnsembleProblemData(problemData)) {
     123      this.trainingPartitions = new Dictionary<IClassificationModel, IntRange>();
     124      this.testPartitions = new Dictionary<IClassificationModel, IntRange>();
    103125      this.classificationSolutions = new CheckedItemCollection<IClassificationSolution>();
    104126
     
    123145      RegisterClassificationSolutionsEventHandler();
    124146      classificationSolutions.AddRange(solutions);
     147      weightCalculator = new MajorityVoteWeightCalculator();
    125148    }
    126149
     
    195218          solution.ProblemData = problemData;
    196219      }
     220      foreach (var trainingPartition in trainingPartitions.Values) {
     221        trainingPartition.Start = ProblemData.TrainingPartition.Start;
     222        trainingPartition.End = ProblemData.TrainingPartition.End;
     223      }
     224      foreach (var testPartition in testPartitions.Values) {
     225        testPartition.Start = ProblemData.TestPartition.Start;
     226        testPartition.End = ProblemData.TestPartition.End;
     227      }
     228
    197229      base.OnProblemDataChanged();
    198230    }
     
    225257      if (Model.Models.Contains(solution.Model)) throw new ArgumentException();
    226258      Model.Add(solution.Model);
     259      trainingPartitions[solution.Model] = solution.ProblemData.TrainingPartition;
     260      testPartitions[solution.Model] = solution.ProblemData.TestPartition;
    227261    }
    228262
     
    230264      if (!Model.Models.Contains(solution.Model)) throw new ArgumentException();
    231265      Model.Remove(solution.Model);
     266      trainingPartitions.Remove(solution.Model);
     267      testPartitions.Remove(solution.Model);
    232268    }
    233269  }
Note: See TracChangeset for help on using the changeset viewer.