Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/08/16 14:37:15 (8 years ago)
Author:
mkommend
Message:

#2604: Merged r13826,r13921, r13922, r13941, r13992, r13993, r14000 intos table.

Location:
stable
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis

  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleModel.cs

    r12702 r14027  
    3232  [StorableClass]
    3333  [Item("ClassificationEnsembleModel", "A classification model that contains an ensemble of multiple classification models")]
    34   public class ClassificationEnsembleModel : NamedItem, IClassificationEnsembleModel {
     34  public class ClassificationEnsembleModel : ClassificationModel, IClassificationEnsembleModel {
     35    public override IEnumerable<string> VariablesUsedForPrediction {
     36      get { return models.SelectMany(x => x.VariablesUsedForPrediction).Distinct().OrderBy(x => x); }
     37    }
    3538
    3639    [Storable]
     
    4952    public ClassificationEnsembleModel() : this(Enumerable.Empty<IClassificationModel>()) { }
    5053    public ClassificationEnsembleModel(IEnumerable<IClassificationModel> models)
    51       : base() {
     54      : base(string.Empty) {
    5255      this.name = ItemName;
    5356      this.description = ItemDescription;
    5457      this.models = new List<IClassificationModel>(models);
     58
     59      if (this.models.Any()) this.TargetVariable = this.models.First().TargetVariable;
    5560    }
    5661
     
    5964    }
    6065
    61     #region IClassificationEnsembleModel Members
    6266    public void Add(IClassificationModel model) {
     67      if (string.IsNullOrEmpty(TargetVariable)) TargetVariable = model.TargetVariable;
    6368      models.Add(model);
    6469    }
    6570    public void Remove(IClassificationModel model) {
    6671      models.Remove(model);
     72      if (!models.Any()) TargetVariable = string.Empty;
    6773    }
    6874
     
    7884    }
    7985
    80     #endregion
    8186
    82     #region IClassificationModel Members
    83 
    84     public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {
     87    public override IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {
    8588      foreach (var estimatedValuesVector in GetEstimatedClassValueVectors(dataset, rows)) {
    8689        // return the class which is most often occuring
     
    9497    }
    9598
    96     IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) {
     99    public override IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
    97100      return new ClassificationEnsembleSolution(models, new ClassificationEnsembleProblemData(problemData));
    98101    }
    99     #endregion
     102
     103
    100104  }
    101105}
  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationModel.cs

    r13941 r14027  
    5555    }
    5656
     57    [StorableHook(HookType.AfterDeserialization)]
     58    private void AfterDeserialization() {
     59      // BackwardsCompatibility3.3
     60      #region Backwards compatible code, remove with 3.4
     61      targetVariable = string.Empty;
     62      #endregion
     63    }
     64
    5765    public abstract IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows);
    5866    public abstract IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData);
  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationModel.cs

    r12702 r14027  
    3333  [StorableClass]
    3434  [Item("DiscriminantFunctionClassificationModel", "Represents a classification model that uses a discriminant function and classification thresholds.")]
    35   public class DiscriminantFunctionClassificationModel : NamedItem, IDiscriminantFunctionClassificationModel {
     35  public class DiscriminantFunctionClassificationModel : ClassificationModel, IDiscriminantFunctionClassificationModel {
     36    public override IEnumerable<string> VariablesUsedForPrediction {
     37      get { return model.VariablesUsedForPrediction; }
     38    }
     39
    3640    [Storable]
    3741    private IRegressionModel model;
     
    7377
    7478    public DiscriminantFunctionClassificationModel(IRegressionModel model, IDiscriminantFunctionThresholdCalculator thresholdCalculator)
    75       : base() {
     79      : base(model.TargetVariable) {
    7680      this.name = ItemName;
    7781      this.description = ItemDescription;
     82
    7883      this.model = model;
    7984      this.classValues = new double[0];
     
    115120    }
    116121
    117     public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {
     122    public override IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {
    118123      if (!Thresholds.Any() && !ClassValues.Any()) throw new ArgumentException("No thresholds and class values were set for the current classification model.");
    119124      foreach (var x in GetEstimatedValues(dataset, rows)) {
     
    135140    #endregion
    136141
    137     public virtual IDiscriminantFunctionClassificationSolution CreateDiscriminantFunctionClassificationSolution(IClassificationProblemData problemData) {
     142    public override IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
     143      return CreateDiscriminantFunctionClassificationSolution(problemData);
     144    }
     145    public virtual IDiscriminantFunctionClassificationSolution CreateDiscriminantFunctionClassificationSolution(
     146      IClassificationProblemData problemData) {
    138147      return new DiscriminantFunctionClassificationSolution(this, new ClassificationProblemData(problemData));
    139     }
    140 
    141     public virtual IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
    142       return CreateDiscriminantFunctionClassificationSolution(problemData);
    143148    }
    144149  }
Note: See TracChangeset for help on using the changeset viewer.