- Timestamp:
- 07/08/16 14:37:15 (8 years ago)
- Location:
- stable
- Files:
-
- 4 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 13826,13921-13922,13941,13992-13993,14000
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis merged: 13826,13921,13941,13992-13993,14000
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleModel.cs
r12702 r14027 32 32 [StorableClass] 33 33 [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 } 35 38 36 39 [Storable] … … 49 52 public ClassificationEnsembleModel() : this(Enumerable.Empty<IClassificationModel>()) { } 50 53 public ClassificationEnsembleModel(IEnumerable<IClassificationModel> models) 51 : base( ) {54 : base(string.Empty) { 52 55 this.name = ItemName; 53 56 this.description = ItemDescription; 54 57 this.models = new List<IClassificationModel>(models); 58 59 if (this.models.Any()) this.TargetVariable = this.models.First().TargetVariable; 55 60 } 56 61 … … 59 64 } 60 65 61 #region IClassificationEnsembleModel Members62 66 public void Add(IClassificationModel model) { 67 if (string.IsNullOrEmpty(TargetVariable)) TargetVariable = model.TargetVariable; 63 68 models.Add(model); 64 69 } 65 70 public void Remove(IClassificationModel model) { 66 71 models.Remove(model); 72 if (!models.Any()) TargetVariable = string.Empty; 67 73 } 68 74 … … 78 84 } 79 85 80 #endregion81 86 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) { 85 88 foreach (var estimatedValuesVector in GetEstimatedClassValueVectors(dataset, rows)) { 86 89 // return the class which is most often occuring … … 94 97 } 95 98 96 IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) {99 public override IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) { 97 100 return new ClassificationEnsembleSolution(models, new ClassificationEnsembleProblemData(problemData)); 98 101 } 99 #endregion 102 103 100 104 } 101 105 } -
stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationModel.cs
r13941 r14027 55 55 } 56 56 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 57 65 public abstract IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows); 58 66 public abstract IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData); -
stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationModel.cs
r12702 r14027 33 33 [StorableClass] 34 34 [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 36 40 [Storable] 37 41 private IRegressionModel model; … … 73 77 74 78 public DiscriminantFunctionClassificationModel(IRegressionModel model, IDiscriminantFunctionThresholdCalculator thresholdCalculator) 75 : base( ) {79 : base(model.TargetVariable) { 76 80 this.name = ItemName; 77 81 this.description = ItemDescription; 82 78 83 this.model = model; 79 84 this.classValues = new double[0]; … … 115 120 } 116 121 117 public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {122 public override IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) { 118 123 if (!Thresholds.Any() && !ClassValues.Any()) throw new ArgumentException("No thresholds and class values were set for the current classification model."); 119 124 foreach (var x in GetEstimatedValues(dataset, rows)) { … … 135 140 #endregion 136 141 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) { 138 147 return new DiscriminantFunctionClassificationSolution(this, new ClassificationProblemData(problemData)); 139 }140 141 public virtual IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {142 return CreateDiscriminantFunctionClassificationSolution(problemData);143 148 } 144 149 }
Note: See TracChangeset
for help on using the changeset viewer.