Changeset 17980 for branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification
- Timestamp:
- 05/10/21 09:48:16 (4 years ago)
- Location:
- branches/2719_HeuristicLab.DatastreamAnalysis
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2719_HeuristicLab.DatastreamAnalysis
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis merged eligible /branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis merged eligible /trunk/HeuristicLab.Problems.DataAnalysis merged eligible /branches/3073_IA_constraint_splitting_reintegration/HeuristicLab.Problems.DataAnalysis 17885-17900 /branches/3105_PythonFormatter/HeuristicLab.Problems.DataAnalysis 17842-17921
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
-
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleModel.cs
r15866 r17980 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 24 24 using HeuristicLab.Common; 25 25 using HeuristicLab.Core; 26 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;26 using HEAL.Attic; 27 27 28 28 namespace HeuristicLab.Problems.DataAnalysis { … … 30 30 /// Represents classification solutions that contain an ensemble of multiple classification models 31 31 /// </summary> 32 [Storable Class]32 [StorableType("0F720A40-5CC2-4E2B-8D4E-CCAD8EB56E43")] 33 33 [Item("ClassificationEnsembleModel", "A classification model that contains an ensemble of multiple classification models")] 34 34 public class ClassificationEnsembleModel : ClassificationModel, IClassificationEnsembleModel { … … 44 44 45 45 [StorableConstructor] 46 protected ClassificationEnsembleModel( bool deserializing) : base(deserializing) { }46 protected ClassificationEnsembleModel(StorableConstructorFlag _) : base(_) { } 47 47 protected ClassificationEnsembleModel(ClassificationEnsembleModel original, Cloner cloner) 48 48 : base(original, cloner) { -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleProblemData.cs
r15866 r17980 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 25 25 using HeuristicLab.Data; 26 26 using HeuristicLab.Parameters; 27 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;27 using HEAL.Attic; 28 28 29 29 namespace HeuristicLab.Problems.DataAnalysis { 30 [Storable Class]30 [StorableType("58768587-0920-4B52-95E4-66B54E8E837C")] 31 31 [Item("ClassificationEnsembleProblemData", "Represents an item containing all data defining a classification problem.")] 32 32 public class ClassificationEnsembleProblemData : ClassificationProblemData { … … 65 65 66 66 [StorableConstructor] 67 protected ClassificationEnsembleProblemData( bool deserializing) : base(deserializing) { }67 protected ClassificationEnsembleProblemData(StorableConstructorFlag _) : base(_) { } 68 68 protected ClassificationEnsembleProblemData(ClassificationEnsembleProblemData original, Cloner cloner) : base(original, cloner) { } 69 69 public override IDeepCloneable Clone(Cloner cloner) { -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleSolution.cs
r15866 r17980 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 27 27 using HeuristicLab.Core; 28 28 using HeuristicLab.Data; 29 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;29 using HEAL.Attic; 30 30 31 31 namespace HeuristicLab.Problems.DataAnalysis { … … 33 33 /// Represents classification solutions that contain an ensemble of multiple classification models 34 34 /// </summary> 35 [Storable Class]35 [StorableType("4CDD22EE-B53D-4899-A77E-C503FF9EBC8E")] 36 36 [Item("Classification Ensemble Solution", "A classification solution that contains an ensemble of multiple classification models")] 37 37 [Creatable(CreatableAttribute.Categories.DataAnalysisEnsembles, Priority = 110)] … … 61 61 62 62 [StorableConstructor] 63 private ClassificationEnsembleSolution(bool deserializing) 64 : base(deserializing) { 63 private ClassificationEnsembleSolution(StorableConstructorFlag _) : base(_) { 65 64 classificationSolutions = new ItemCollection<IClassificationSolution>(); 66 65 } -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationModel.cs
r15866 r17980 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 24 24 using HeuristicLab.Common; 25 25 using HeuristicLab.Core; 26 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;26 using HEAL.Attic; 27 27 28 28 namespace HeuristicLab.Problems.DataAnalysis { 29 [Storable Class]29 [StorableType("7E6091F9-86FD-4C47-8935-9C35CAB4261B")] 30 30 [Item("Classification Model", "Base class for all classification models.")] 31 31 public abstract class ClassificationModel : DataAnalysisModel, IClassificationModel { … … 41 41 } 42 42 43 protected ClassificationModel(bool deserializing) 44 : base(deserializing) { 43 [StorableConstructor] 44 protected ClassificationModel(StorableConstructorFlag _) 45 : base(_) { 45 46 targetVariable = string.Empty; 46 47 } … … 66 67 public abstract IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData); 67 68 69 public virtual bool IsProblemDataCompatible(IClassificationProblemData problemData, out string errorMessage) { 70 return IsProblemDataCompatible(this, problemData, out errorMessage); 71 } 72 73 public override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) { 74 if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null."); 75 var classificationProblemData = problemData as IClassificationProblemData; 76 if (classificationProblemData == null) 77 throw new ArgumentException("The problem data is not compatible with this classification model. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData"); 78 return IsProblemDataCompatible(classificationProblemData, out errorMessage); 79 } 80 81 public static bool IsProblemDataCompatible(IClassificationModel model, IClassificationProblemData problemData, out string errorMessage) { 82 if (model == null) throw new ArgumentNullException("model", "The provided model is null."); 83 if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null."); 84 errorMessage = string.Empty; 85 86 if (model.TargetVariable != problemData.TargetVariable) 87 errorMessage = string.Format("The target variable of the model {0} does not match the target variable of the problemData {1}.", model.TargetVariable, problemData.TargetVariable); 88 89 var evaluationErrorMessage = string.Empty; 90 var datasetCompatible = model.IsDatasetCompatible(problemData.Dataset, out evaluationErrorMessage); 91 if (!datasetCompatible) 92 errorMessage += evaluationErrorMessage; 93 94 return string.IsNullOrEmpty(errorMessage); 95 } 96 68 97 #region events 69 98 public event EventHandler TargetVariableChanged; -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationPerformanceMeasures.cs
r15866 r17980 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 24 24 using HeuristicLab.Data; 25 25 using HeuristicLab.Optimization; 26 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;26 using HEAL.Attic; 27 27 28 28 namespace HeuristicLab.Problems.DataAnalysis { 29 [Storable Class]29 [StorableType("6F44E140-22CF-48D3-B100-B6013F2B6608")] 30 30 public class ClassificationPerformanceMeasuresResultCollection : ResultCollection { 31 31 #region result names … … 54 54 } 55 55 [StorableConstructor] 56 protected ClassificationPerformanceMeasuresResultCollection(bool deserializing) 57 : base(deserializing) { 56 protected ClassificationPerformanceMeasuresResultCollection(StorableConstructorFlag _) : base(_) { 58 57 } 59 58 -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblem.cs
r15866 r17980 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;24 using HEAL.Attic; 25 25 26 26 namespace HeuristicLab.Problems.DataAnalysis { 27 [Storable Class]27 [StorableType("93696570-A410-4885-A210-7220771B6050")] 28 28 [Item("Classification Problem", "A general classification problem.")] 29 29 public class ClassificationProblem : DataAnalysisProblem<IClassificationProblemData>, IClassificationProblem, IStorableContent { … … 31 31 32 32 [StorableConstructor] 33 protected ClassificationProblem( bool deserializing) : base(deserializing) { }33 protected ClassificationProblem(StorableConstructorFlag _) : base(_) { } 34 34 protected ClassificationProblem(ClassificationProblem original, Cloner cloner) : base(original, cloner) { } 35 35 public override IDeepCloneable Clone(Cloner cloner) { return new ClassificationProblem(this, cloner); } -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblemData.cs
r15866 r17980 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 27 27 using HeuristicLab.Data; 28 28 using HeuristicLab.Parameters; 29 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;29 using HEAL.Attic; 30 30 31 31 namespace HeuristicLab.Problems.DataAnalysis { 32 [Storable Class]32 [StorableType("1C8DCCCF-4E2A-421D-9C61-7C017D584054")] 33 33 [Item("ClassificationProblemData", "Represents an item containing all data defining a classification problem.")] 34 34 public class ClassificationProblemData : DataAnalysisProblemData, IClassificationProblemData, IStorableContent { … … 279 279 280 280 [StorableConstructor] 281 protected ClassificationProblemData( bool deserializing) : base(deserializing) { }281 protected ClassificationProblemData(StorableConstructorFlag _) : base(_) { } 282 282 [StorableHook(HookType.AfterDeserialization)] 283 283 private void AfterDeserialization() { … … 467 467 } 468 468 #endregion 469 470 protected override bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) {471 if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");472 IClassificationProblemData classificationProblemData = problemData as IClassificationProblemData;473 if (classificationProblemData == null)474 throw new ArgumentException("The problem data is no classification problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");475 476 var returnValue = base.IsProblemDataCompatible(classificationProblemData, out errorMessage);477 //check targetVariable478 if (classificationProblemData.InputVariables.All(var => var.Value != TargetVariable)) {479 errorMessage = string.Format("The target variable {0} is not present in the new problem data.", TargetVariable)480 + Environment.NewLine + errorMessage;481 return false;482 }483 484 var newClassValues = classificationProblemData.Dataset.GetDoubleValues(TargetVariable).Distinct().OrderBy(x => x);485 if (!newClassValues.SequenceEqual(ClassValues)) {486 errorMessage = errorMessage + string.Format("The class values differ in the provided classification problem data.");487 returnValue = false;488 }489 490 var newPositivieClassName = classificationProblemData.PositiveClass;491 if (newPositivieClassName != PositiveClass) {492 errorMessage = errorMessage + string.Format("The positive class differs in the provided classification problem data.");493 returnValue = false;494 }495 496 return returnValue;497 }498 499 public override void AdjustProblemDataProperties(IDataAnalysisProblemData problemData) {500 if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null.");501 ClassificationProblemData classificationProblemData = problemData as ClassificationProblemData;502 if (classificationProblemData == null)503 throw new ArgumentException("The problem data is not a classification problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData");504 505 base.AdjustProblemDataProperties(problemData);506 TargetVariable = classificationProblemData.TargetVariable;507 for (int i = 0; i < classificationProblemData.ClassNames.Count(); i++)508 ClassNamesParameter.Value[i, 0] = classificationProblemData.ClassNames.ElementAt(i);509 510 PositiveClass = classificationProblemData.PositiveClass;511 512 for (int i = 0; i < Classes; i++) {513 for (int j = 0; j < Classes; j++) {514 ClassificationPenaltiesParameter.Value[i, j] = classificationProblemData.GetClassificationPenalty(ClassValuesCache[i], ClassValuesCache[j]);515 }516 }517 }518 469 } 519 470 } -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolution.cs
r15866 r17980 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 23 23 using System.Linq; 24 24 using HeuristicLab.Common; 25 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;25 using HEAL.Attic; 26 26 27 27 namespace HeuristicLab.Problems.DataAnalysis { … … 29 29 /// Represents a classification data analysis solution 30 30 /// </summary> 31 [Storable Class]31 [StorableType("A240D831-23D6-4432-A105-12D02D2EA75A")] 32 32 public class ClassificationSolution : ClassificationSolutionBase { 33 33 protected readonly Dictionary<int, double> evaluationCache; 34 34 35 35 [StorableConstructor] 36 protected ClassificationSolution(bool deserializing) 37 : base(deserializing) { 36 protected ClassificationSolution(StorableConstructorFlag _) : base(_) { 38 37 evaluationCache = new Dictionary<int, double>(); 39 38 } -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolutionBase.cs
r15866 r17980 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 25 26 using HeuristicLab.Data; 26 27 using HeuristicLab.Optimization; 27 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;28 using HEAL.Attic; 28 29 using HeuristicLab.Problems.DataAnalysis.OnlineCalculators; 29 30 30 31 namespace HeuristicLab.Problems.DataAnalysis { 31 [Storable Class]32 [StorableType("60599497-EAF0-4DB0-B2E4-D58F34458D8F")] 32 33 public abstract class ClassificationSolutionBase : DataAnalysisSolution, IClassificationSolution { 33 34 private const string TrainingAccuracyResultName = "Accuracy (training)"; … … 44 45 public new IClassificationProblemData ProblemData { 45 46 get { return (IClassificationProblemData)base.ProblemData; } 46 set { base.ProblemData = value; } 47 set { 48 if (value == null) throw new ArgumentNullException("The problemData must not be null."); 49 string errorMessage = string.Empty; 50 if (!Model.IsProblemDataCompatible(value, out errorMessage)) throw new ArgumentException(errorMessage); 51 52 base.ProblemData = value; 53 } 47 54 } 48 55 … … 71 78 72 79 [StorableConstructor] 73 protected ClassificationSolutionBase( bool deserializing) : base(deserializing) { }80 protected ClassificationSolutionBase(StorableConstructorFlag _) : base(_) { } 74 81 protected ClassificationSolutionBase(ClassificationSolutionBase original, Cloner cloner) 75 82 : base(original, cloner) { -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolutionVariableImpactsCalculator.cs
r15866 r17980 2 2 3 3 /* HeuristicLab 4 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)4 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 5 5 * 6 6 * This file is part of HeuristicLab. … … 23 23 24 24 using System; 25 using System.Collections; 25 26 using System.Collections.Generic; 26 27 using System.Linq; … … 29 30 using HeuristicLab.Data; 30 31 using HeuristicLab.Parameters; 31 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;32 using HEAL.Attic; 32 33 using HeuristicLab.Random; 33 34 34 35 namespace HeuristicLab.Problems.DataAnalysis { 35 [Storable Class]36 [StorableType("768AFEDB-5641-429E-85A1-A0BE8DFDD56F")] 36 37 [Item("ClassificationSolution Impacts Calculator", "Calculation of the impacts of input variables for any classification solution")] 37 38 public sealed class ClassificationSolutionVariableImpactsCalculator : ParameterizedNamedItem { 39 #region Parameters/Properties 40 [StorableType("e6cd2226-10cd-4765-ae1a-924e316b6aac")] 38 41 public enum ReplacementMethodEnum { 39 42 Median, … … 42 45 Noise 43 46 } 47 48 [StorableType("84d84ccf-5d6d-432f-a946-eb499935e5c8")] 44 49 public enum FactorReplacementMethodEnum { 45 50 Best, … … 47 52 Shuffle 48 53 } 54 55 [StorableType("70f30113-df01-41b4-9e3b-2982035de498")] 49 56 public enum DataPartitionEnum { 50 57 Training, … … 54 61 55 62 private const string ReplacementParameterName = "Replacement Method"; 63 private const string FactorReplacementParameterName = "Factor Replacement Method"; 56 64 private const string DataPartitionParameterName = "DataPartition"; 57 65 58 66 public IFixedValueParameter<EnumValue<ReplacementMethodEnum>> ReplacementParameter { 59 67 get { return (IFixedValueParameter<EnumValue<ReplacementMethodEnum>>)Parameters[ReplacementParameterName]; } 68 } 69 public IFixedValueParameter<EnumValue<FactorReplacementMethodEnum>> FactorReplacementParameter { 70 get { return (IFixedValueParameter<EnumValue<FactorReplacementMethodEnum>>)Parameters[FactorReplacementParameterName]; } 60 71 } 61 72 public IFixedValueParameter<EnumValue<DataPartitionEnum>> DataPartitionParameter { … … 67 78 set { ReplacementParameter.Value.Value = value; } 68 79 } 80 public FactorReplacementMethodEnum FactorReplacementMethod { 81 get { return FactorReplacementParameter.Value.Value; } 82 set { FactorReplacementParameter.Value.Value = value; } 83 } 69 84 public DataPartitionEnum DataPartition { 70 85 get { return DataPartitionParameter.Value.Value; } 71 86 set { DataPartitionParameter.Value.Value = value; } 72 87 } 73 74 88 #endregion 89 90 #region Ctor/Cloner 75 91 [StorableConstructor] 76 private ClassificationSolutionVariableImpactsCalculator( bool deserializing) : base(deserializing) { }92 private ClassificationSolutionVariableImpactsCalculator(StorableConstructorFlag _) : base(_) { } 77 93 private ClassificationSolutionVariableImpactsCalculator(ClassificationSolutionVariableImpactsCalculator original, Cloner cloner) 78 94 : base(original, cloner) { } 95 public ClassificationSolutionVariableImpactsCalculator() 96 : base() { 97 Parameters.Add(new FixedValueParameter<EnumValue<ReplacementMethodEnum>>(ReplacementParameterName, "The replacement method for variables during impact calculation.", new EnumValue<ReplacementMethodEnum>(ReplacementMethodEnum.Shuffle))); 98 Parameters.Add(new FixedValueParameter<EnumValue<FactorReplacementMethodEnum>>(FactorReplacementParameterName, "The replacement method for factor variables during impact calculation.", new EnumValue<FactorReplacementMethodEnum>(FactorReplacementMethodEnum.Best))); 99 Parameters.Add(new FixedValueParameter<EnumValue<DataPartitionEnum>>(DataPartitionParameterName, "The data partition on which the impacts are calculated.", new EnumValue<DataPartitionEnum>(DataPartitionEnum.Training))); 100 } 101 79 102 public override IDeepCloneable Clone(Cloner cloner) { 80 103 return new ClassificationSolutionVariableImpactsCalculator(this, cloner); 81 104 } 82 83 public ClassificationSolutionVariableImpactsCalculator() 84 : base() { 85 Parameters.Add(new FixedValueParameter<EnumValue<ReplacementMethodEnum>>(ReplacementParameterName, "The replacement method for variables during impact calculation.", new EnumValue<ReplacementMethodEnum>(ReplacementMethodEnum.Median))); 86 Parameters.Add(new FixedValueParameter<EnumValue<DataPartitionEnum>>(DataPartitionParameterName, "The data partition on which the impacts are calculated.", new EnumValue<DataPartitionEnum>(DataPartitionEnum.Training))); 87 } 105 #endregion 88 106 89 107 //mkommend: annoying name clash with static method, open to better naming suggestions 90 108 public IEnumerable<Tuple<string, double>> Calculate(IClassificationSolution solution) { 91 return CalculateImpacts(solution, DataPartition, ReplacementMethod);109 return CalculateImpacts(solution, ReplacementMethod, FactorReplacementMethod, DataPartition); 92 110 } 93 111 94 112 public static IEnumerable<Tuple<string, double>> CalculateImpacts( 95 113 IClassificationSolution solution, 96 DataPartitionEnum data = DataPartitionEnum.Training, 97 ReplacementMethodEnum replacementMethod = ReplacementMethodEnum.Median, 114 ReplacementMethodEnum replacementMethod = ReplacementMethodEnum.Shuffle, 115 FactorReplacementMethodEnum factorReplacementMethod = FactorReplacementMethodEnum.Best, 116 DataPartitionEnum dataPartition = DataPartitionEnum.Training) { 117 118 IEnumerable<int> rows = GetPartitionRows(dataPartition, solution.ProblemData); 119 IEnumerable<double> estimatedClassValues = solution.GetEstimatedClassValues(rows); 120 var model = (IClassificationModel)solution.Model.Clone(); //mkommend: clone of model is necessary, because the thresholds for IDiscriminantClassificationModels are updated 121 122 return CalculateImpacts(model, solution.ProblemData, estimatedClassValues, rows, replacementMethod, factorReplacementMethod); 123 } 124 125 public static IEnumerable<Tuple<string, double>> CalculateImpacts( 126 IClassificationModel model, 127 IClassificationProblemData problemData, 128 IEnumerable<double> estimatedClassValues, 129 IEnumerable<int> rows, 130 ReplacementMethodEnum replacementMethod = ReplacementMethodEnum.Shuffle, 131 FactorReplacementMethodEnum factorReplacementMethod = FactorReplacementMethodEnum.Best) { 132 133 //fholzing: try and catch in case a different dataset is loaded, otherwise statement is neglectable 134 var missingVariables = model.VariablesUsedForPrediction.Except(problemData.Dataset.VariableNames); 135 if (missingVariables.Any()) { 136 throw new InvalidOperationException(string.Format("Can not calculate variable impacts, because the model uses inputs missing in the dataset ({0})", string.Join(", ", missingVariables))); 137 } 138 IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 139 var originalQuality = CalculateQuality(targetValues, estimatedClassValues); 140 141 var impacts = new Dictionary<string, double>(); 142 var inputvariables = new HashSet<string>(problemData.AllowedInputVariables.Union(model.VariablesUsedForPrediction)); 143 var modifiableDataset = ((Dataset)(problemData.Dataset).Clone()).ToModifiable(); 144 145 foreach (var inputVariable in inputvariables) { 146 impacts[inputVariable] = CalculateImpact(inputVariable, model, problemData, modifiableDataset, rows, replacementMethod, factorReplacementMethod, targetValues, originalQuality); 147 } 148 149 return impacts.Select(i => Tuple.Create(i.Key, i.Value)); 150 } 151 152 public static double CalculateImpact(string variableName, 153 IClassificationModel model, 154 IClassificationProblemData problemData, 155 ModifiableDataset modifiableDataset, 156 IEnumerable<int> rows, 157 ReplacementMethodEnum replacementMethod = ReplacementMethodEnum.Shuffle, 158 FactorReplacementMethodEnum factorReplacementMethod = FactorReplacementMethodEnum.Best, 159 IEnumerable<double> targetValues = null, 160 double quality = double.NaN) { 161 162 if (!model.VariablesUsedForPrediction.Contains(variableName)) { return 0.0; } 163 if (!problemData.Dataset.VariableNames.Contains(variableName)) { 164 throw new InvalidOperationException(string.Format("Can not calculate variable impact, because the model uses inputs missing in the dataset ({0})", variableName)); 165 } 166 167 if (targetValues == null) { 168 targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 169 } 170 if (quality == double.NaN) { 171 quality = CalculateQuality(model.GetEstimatedClassValues(modifiableDataset, rows), targetValues); 172 } 173 174 IList originalValues = null; 175 IList replacementValues = GetReplacementValues(modifiableDataset, variableName, model, rows, targetValues, out originalValues, replacementMethod, factorReplacementMethod); 176 177 double newValue = CalculateQualityForReplacement(model, modifiableDataset, variableName, originalValues, rows, replacementValues, targetValues); 178 double impact = quality - newValue; 179 180 return impact; 181 } 182 183 private static IList GetReplacementValues(ModifiableDataset modifiableDataset, 184 string variableName, 185 IClassificationModel model, 186 IEnumerable<int> rows, 187 IEnumerable<double> targetValues, 188 out IList originalValues, 189 ReplacementMethodEnum replacementMethod = ReplacementMethodEnum.Shuffle, 98 190 FactorReplacementMethodEnum factorReplacementMethod = FactorReplacementMethodEnum.Best) { 99 191 100 var problemData = solution.ProblemData; 101 var dataset = problemData.Dataset; 102 103 IEnumerable<int> rows; 104 IEnumerable<double> targetValues; 105 double originalAccuracy; 106 107 OnlineCalculatorError error; 108 109 switch (data) { 110 case DataPartitionEnum.All: 111 rows = problemData.AllIndices; 112 targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.AllIndices).ToList(); 113 originalAccuracy = OnlineAccuracyCalculator.Calculate(targetValues, solution.EstimatedClassValues, out error); 114 if (error != OnlineCalculatorError.None) throw new InvalidOperationException("Error during accuracy calculation."); 115 break; 116 case DataPartitionEnum.Training: 117 rows = problemData.TrainingIndices; 118 targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TrainingIndices).ToList(); 119 originalAccuracy = OnlineAccuracyCalculator.Calculate(targetValues, solution.EstimatedTrainingClassValues, out error); 120 if (error != OnlineCalculatorError.None) throw new InvalidOperationException("Error during accuracy calculation."); 121 break; 122 case DataPartitionEnum.Test: 123 rows = problemData.TestIndices; 124 targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TestIndices).ToList(); 125 originalAccuracy = OnlineAccuracyCalculator.Calculate(targetValues, solution.EstimatedTestClassValues, out error); 126 if (error != OnlineCalculatorError.None) throw new InvalidOperationException("Error during accuracy calculation."); 127 break; 128 default: throw new ArgumentException(string.Format("DataPartition {0} cannot be handled.", data)); 129 } 130 131 var impacts = new Dictionary<string, double>(); 132 var modifiableDataset = ((Dataset)dataset).ToModifiable(); 133 134 var inputvariables = new HashSet<string>(problemData.AllowedInputVariables.Union(solution.Model.VariablesUsedForPrediction)); 135 var allowedInputVariables = dataset.VariableNames.Where(v => inputvariables.Contains(v)).ToList(); 136 137 // calculate impacts for double variables 138 foreach (var inputVariable in allowedInputVariables.Where(problemData.Dataset.VariableHasType<double>)) { 139 var newEstimates = EvaluateModelWithReplacedVariable(solution.Model, inputVariable, modifiableDataset, rows, replacementMethod); 140 var newAccuracy = OnlineAccuracyCalculator.Calculate(targetValues, newEstimates, out error); 141 if (error != OnlineCalculatorError.None) throw new InvalidOperationException("Error during R² calculation with replaced inputs."); 142 143 impacts[inputVariable] = originalAccuracy - newAccuracy; 144 } 145 146 // calculate impacts for string variables 147 foreach (var inputVariable in allowedInputVariables.Where(problemData.Dataset.VariableHasType<string>)) { 148 if (factorReplacementMethod == FactorReplacementMethodEnum.Best) { 149 // try replacing with all possible values and find the best replacement value 150 var smallestImpact = double.PositiveInfinity; 151 foreach (var repl in problemData.Dataset.GetStringValues(inputVariable, rows).Distinct()) { 152 var newEstimates = EvaluateModelWithReplacedVariable(solution.Model, inputVariable, modifiableDataset, rows, 153 Enumerable.Repeat(repl, dataset.Rows)); 154 var newAccuracy = OnlineAccuracyCalculator.Calculate(targetValues, newEstimates, out error); 155 if (error != OnlineCalculatorError.None) 156 throw new InvalidOperationException("Error during accuracy calculation with replaced inputs."); 157 158 var impact = originalAccuracy - newAccuracy; 159 if (impact < smallestImpact) smallestImpact = impact; 160 } 161 impacts[inputVariable] = smallestImpact; 162 } else { 163 // for replacement methods shuffle and mode 164 // calculate impacts for factor variables 165 166 var newEstimates = EvaluateModelWithReplacedVariable(solution.Model, inputVariable, modifiableDataset, rows, 167 factorReplacementMethod); 168 var newAccuracy = OnlineAccuracyCalculator.Calculate(targetValues, newEstimates, out error); 169 if (error != OnlineCalculatorError.None) 170 throw new InvalidOperationException("Error during accuracy calculation with replaced inputs."); 171 172 impacts[inputVariable] = originalAccuracy - newAccuracy; 173 } 174 } // foreach 175 return impacts.OrderByDescending(i => i.Value).Select(i => Tuple.Create(i.Key, i.Value)); 176 } 177 178 private static IEnumerable<double> EvaluateModelWithReplacedVariable(IClassificationModel model, string variable, ModifiableDataset dataset, IEnumerable<int> rows, ReplacementMethodEnum replacement = ReplacementMethodEnum.Median) { 179 var originalValues = dataset.GetReadOnlyDoubleValues(variable).ToList(); 192 IList replacementValues = null; 193 if (modifiableDataset.VariableHasType<double>(variableName)) { 194 originalValues = modifiableDataset.GetReadOnlyDoubleValues(variableName).ToList(); 195 replacementValues = GetReplacementValuesForDouble(modifiableDataset, rows, (List<double>)originalValues, replacementMethod); 196 } else if (modifiableDataset.VariableHasType<string>(variableName)) { 197 originalValues = modifiableDataset.GetReadOnlyStringValues(variableName).ToList(); 198 replacementValues = GetReplacementValuesForString(model, modifiableDataset, variableName, rows, (List<string>)originalValues, targetValues, factorReplacementMethod); 199 } else { 200 throw new NotSupportedException("Variable not supported"); 201 } 202 203 return replacementValues; 204 } 205 206 private static IList GetReplacementValuesForDouble(ModifiableDataset modifiableDataset, 207 IEnumerable<int> rows, 208 List<double> originalValues, 209 ReplacementMethodEnum replacementMethod = ReplacementMethodEnum.Shuffle) { 210 211 IRandom random = new FastRandom(31415); 212 List<double> replacementValues; 180 213 double replacementValue; 181 List<double> replacementValues; 182 IRandom rand; 183 184 switch (replacement) { 214 215 switch (replacementMethod) { 185 216 case ReplacementMethodEnum.Median: 186 217 replacementValue = rows.Select(r => originalValues[r]).Median(); 187 replacementValues = Enumerable.Repeat(replacementValue, dataset.Rows).ToList();218 replacementValues = Enumerable.Repeat(replacementValue, modifiableDataset.Rows).ToList(); 188 219 break; 189 220 case ReplacementMethodEnum.Average: 190 221 replacementValue = rows.Select(r => originalValues[r]).Average(); 191 replacementValues = Enumerable.Repeat(replacementValue, dataset.Rows).ToList();222 replacementValues = Enumerable.Repeat(replacementValue, modifiableDataset.Rows).ToList(); 192 223 break; 193 224 case ReplacementMethodEnum.Shuffle: 194 225 // new var has same empirical distribution but the relation to y is broken 195 rand = new FastRandom(31415);196 226 // prepare a complete column for the dataset 197 replacementValues = Enumerable.Repeat(double.NaN, dataset.Rows).ToList();227 replacementValues = Enumerable.Repeat(double.NaN, modifiableDataset.Rows).ToList(); 198 228 // shuffle only the selected rows 199 var shuffledValues = rows.Select(r => originalValues[r]).Shuffle(rand ).ToList();229 var shuffledValues = rows.Select(r => originalValues[r]).Shuffle(random).ToList(); 200 230 int i = 0; 201 231 // update column values … … 207 237 var avg = rows.Select(r => originalValues[r]).Average(); 208 238 var stdDev = rows.Select(r => originalValues[r]).StandardDeviation(); 209 rand = new FastRandom(31415);210 239 // prepare a complete column for the dataset 211 replacementValues = Enumerable.Repeat(double.NaN, dataset.Rows).ToList();240 replacementValues = Enumerable.Repeat(double.NaN, modifiableDataset.Rows).ToList(); 212 241 // update column values 213 242 foreach (var r in rows) { 214 replacementValues[r] = NormalDistributedRandom.NextDouble(rand , avg, stdDev);243 replacementValues[r] = NormalDistributedRandom.NextDouble(random, avg, stdDev); 215 244 } 216 245 break; 217 246 218 247 default: 219 throw new ArgumentException(string.Format("ReplacementMethod {0} cannot be handled.", replacement)); 220 } 221 222 return EvaluateModelWithReplacedVariable(model, variable, dataset, rows, replacementValues); 223 } 224 225 private static IEnumerable<double> EvaluateModelWithReplacedVariable( 226 IClassificationModel model, string variable, ModifiableDataset dataset, 227 IEnumerable<int> rows, 228 FactorReplacementMethodEnum replacement = FactorReplacementMethodEnum.Shuffle) { 229 var originalValues = dataset.GetReadOnlyStringValues(variable).ToList(); 230 List<string> replacementValues; 231 IRandom rand; 232 233 switch (replacement) { 248 throw new ArgumentException(string.Format("ReplacementMethod {0} cannot be handled.", replacementMethod)); 249 } 250 251 return replacementValues; 252 } 253 254 private static IList GetReplacementValuesForString(IClassificationModel model, 255 ModifiableDataset modifiableDataset, 256 string variableName, 257 IEnumerable<int> rows, 258 List<string> originalValues, 259 IEnumerable<double> targetValues, 260 FactorReplacementMethodEnum factorReplacementMethod = FactorReplacementMethodEnum.Shuffle) { 261 262 List<string> replacementValues = null; 263 IRandom random = new FastRandom(31415); 264 265 switch (factorReplacementMethod) { 266 case FactorReplacementMethodEnum.Best: 267 // try replacing with all possible values and find the best replacement value 268 var bestQuality = double.NegativeInfinity; 269 foreach (var repl in modifiableDataset.GetStringValues(variableName, rows).Distinct()) { 270 List<string> curReplacementValues = Enumerable.Repeat(repl, modifiableDataset.Rows).ToList(); 271 //fholzing: this result could be used later on (theoretically), but is neglected for better readability/method consistency 272 var newValue = CalculateQualityForReplacement(model, modifiableDataset, variableName, originalValues, rows, curReplacementValues, targetValues); 273 var curQuality = newValue; 274 275 if (curQuality > bestQuality) { 276 bestQuality = curQuality; 277 replacementValues = curReplacementValues; 278 } 279 } 280 break; 234 281 case FactorReplacementMethodEnum.Mode: 235 282 var mostCommonValue = rows.Select(r => originalValues[r]) … … 237 284 .OrderByDescending(g => g.Count()) 238 285 .First().Key; 239 replacementValues = Enumerable.Repeat(mostCommonValue, dataset.Rows).ToList();286 replacementValues = Enumerable.Repeat(mostCommonValue, modifiableDataset.Rows).ToList(); 240 287 break; 241 288 case FactorReplacementMethodEnum.Shuffle: 242 289 // new var has same empirical distribution but the relation to y is broken 243 rand = new FastRandom(31415);244 290 // prepare a complete column for the dataset 245 replacementValues = Enumerable.Repeat(string.Empty, dataset.Rows).ToList();291 replacementValues = Enumerable.Repeat(string.Empty, modifiableDataset.Rows).ToList(); 246 292 // shuffle only the selected rows 247 var shuffledValues = rows.Select(r => originalValues[r]).Shuffle(rand ).ToList();293 var shuffledValues = rows.Select(r => originalValues[r]).Shuffle(random).ToList(); 248 294 int i = 0; 249 295 // update column values … … 253 299 break; 254 300 default: 255 throw new ArgumentException(string.Format("FactorReplacementMethod {0} cannot be handled.", replacement)); 256 } 257 258 return EvaluateModelWithReplacedVariable(model, variable, dataset, rows, replacementValues); 259 } 260 261 private static IEnumerable<double> EvaluateModelWithReplacedVariable(IClassificationModel model, string variable, 262 ModifiableDataset dataset, IEnumerable<int> rows, IEnumerable<double> replacementValues) { 263 var originalValues = dataset.GetReadOnlyDoubleValues(variable).ToList(); 264 dataset.ReplaceVariable(variable, replacementValues.ToList()); 301 throw new ArgumentException(string.Format("FactorReplacementMethod {0} cannot be handled.", factorReplacementMethod)); 302 } 303 304 return replacementValues; 305 } 306 307 private static double CalculateQualityForReplacement( 308 IClassificationModel model, 309 ModifiableDataset modifiableDataset, 310 string variableName, 311 IList originalValues, 312 IEnumerable<int> rows, 313 IList replacementValues, 314 IEnumerable<double> targetValues) { 315 316 modifiableDataset.ReplaceVariable(variableName, replacementValues); 317 var discModel = model as IDiscriminantFunctionClassificationModel; 318 if (discModel != null) { 319 var problemData = new ClassificationProblemData(modifiableDataset, modifiableDataset.VariableNames, model.TargetVariable); 320 discModel.RecalculateModelParameters(problemData, rows); 321 } 322 265 323 //mkommend: ToList is used on purpose to avoid lazy evaluation that could result in wrong estimates due to variable replacements 266 var estimates = model.GetEstimatedClassValues(dataset, rows).ToList(); 267 dataset.ReplaceVariable(variable, originalValues); 268 269 return estimates; 270 } 271 private static IEnumerable<double> EvaluateModelWithReplacedVariable(IClassificationModel model, string variable, 272 ModifiableDataset dataset, IEnumerable<int> rows, IEnumerable<string> replacementValues) { 273 var originalValues = dataset.GetReadOnlyStringValues(variable).ToList(); 274 dataset.ReplaceVariable(variable, replacementValues.ToList()); 275 //mkommend: ToList is used on purpose to avoid lazy evaluation that could result in wrong estimates due to variable replacements 276 var estimates = model.GetEstimatedClassValues(dataset, rows).ToList(); 277 dataset.ReplaceVariable(variable, originalValues); 278 279 return estimates; 324 var estimates = model.GetEstimatedClassValues(modifiableDataset, rows).ToList(); 325 var ret = CalculateQuality(targetValues, estimates); 326 modifiableDataset.ReplaceVariable(variableName, originalValues); 327 328 return ret; 329 } 330 331 public static double CalculateQuality(IEnumerable<double> targetValues, IEnumerable<double> estimatedClassValues) { 332 OnlineCalculatorError errorState; 333 var ret = OnlineAccuracyCalculator.Calculate(targetValues, estimatedClassValues, out errorState); 334 if (errorState != OnlineCalculatorError.None) { throw new InvalidOperationException("Error during calculation with replaced inputs."); } 335 return ret; 336 } 337 338 public static IEnumerable<int> GetPartitionRows(DataPartitionEnum dataPartition, IClassificationProblemData problemData) { 339 IEnumerable<int> rows; 340 341 switch (dataPartition) { 342 case DataPartitionEnum.All: 343 rows = problemData.AllIndices; 344 break; 345 case DataPartitionEnum.Test: 346 rows = problemData.TestIndices; 347 break; 348 case DataPartitionEnum.Training: 349 rows = problemData.TrainingIndices; 350 break; 351 default: 352 throw new NotSupportedException("DataPartition not supported"); 353 } 354 355 return rows; 280 356 } 281 357 } -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ConstantClassificationSolution.cs
r15866 r17980 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;24 using HEAL.Attic; 25 25 26 26 namespace HeuristicLab.Problems.DataAnalysis { 27 [Storable Class]27 [StorableType("D5A42FE7-D21B-48F7-A812-FE69724D0098")] 28 28 [Item(Name = "Constant Classification Solution", Description = "Represents a constant classification solution (model + data).")] 29 29 public class ConstantClassificationSolution : ClassificationSolution { … … 34 34 35 35 [StorableConstructor] 36 protected ConstantClassificationSolution( bool deserializing) : base(deserializing) { }36 protected ConstantClassificationSolution(StorableConstructorFlag _) : base(_) { } 37 37 protected ConstantClassificationSolution(ConstantClassificationSolution original, Cloner cloner) : base(original, cloner) { } 38 38 public ConstantClassificationSolution(ConstantModel model, IClassificationProblemData problemData) -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationModel.cs
r15866 r17980 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;28 28 29 29 namespace HeuristicLab.Problems.DataAnalysis { … … 31 31 /// Represents discriminant function classification data analysis models. 32 32 /// </summary> 33 [Storable Class]33 [StorableType("E7A8648D-C938-499F-A712-185542095708")] 34 34 [Item("DiscriminantFunctionClassificationModel", "Represents a classification model that uses a discriminant function and classification thresholds.")] 35 35 public class DiscriminantFunctionClassificationModel : ClassificationModel, IDiscriminantFunctionClassificationModel { … … 68 68 69 69 [StorableConstructor] 70 protected DiscriminantFunctionClassificationModel( bool deserializing) : base(deserializing) { }70 protected DiscriminantFunctionClassificationModel(StorableConstructorFlag _) : base(_) { } 71 71 protected DiscriminantFunctionClassificationModel(DiscriminantFunctionClassificationModel original, Cloner cloner) 72 72 : base(original, cloner) { … … 121 121 122 122 public override IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) { 123 var estimatedValues = GetEstimatedValues(dataset, rows); 124 return GetEstimatedClassValues(estimatedValues); 125 } 126 127 public virtual IEnumerable<double> GetEstimatedClassValues(IEnumerable<double> estimatedValues) { 123 128 if (!Thresholds.Any() && !ClassValues.Any()) throw new ArgumentException("No thresholds and class values were set for the current classification model."); 124 foreach (var x in GetEstimatedValues(dataset, rows)) {129 foreach (var x in estimatedValues) { 125 130 int classIndex = 0; 126 131 // find first threshold value which is larger than x => class index = threshold index + 1 … … 132 137 } 133 138 } 139 134 140 #region events 135 141 public event EventHandler ThresholdsChanged; -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolution.cs
r15866 r17980 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 24 24 using HeuristicLab.Common; 25 25 using HeuristicLab.Core; 26 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;26 using HEAL.Attic; 27 27 28 28 namespace HeuristicLab.Problems.DataAnalysis { … … 30 30 /// Represents a classification solution that uses a discriminant function and classification thresholds. 31 31 /// </summary> 32 [Storable Class]32 [StorableType("A3480DF9-49E7-4329-AD23-57B4441033C1")] 33 33 [Item("DiscriminantFunctionClassificationSolution", "Represents a classification solution that uses a discriminant function and classification thresholds.")] 34 34 public class DiscriminantFunctionClassificationSolution : DiscriminantFunctionClassificationSolutionBase { … … 37 37 38 38 [StorableConstructor] 39 protected DiscriminantFunctionClassificationSolution(bool deserializing) 40 : base(deserializing) { 39 protected DiscriminantFunctionClassificationSolution(StorableConstructorFlag _) : base(_) { 41 40 valueEvaluationCache = new Dictionary<int, double>(); 42 41 classValueEvaluationCache = new Dictionary<int, double>(); -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolutionBase.cs
r15866 r17980 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 27 27 using HeuristicLab.Data; 28 28 using HeuristicLab.Optimization; 29 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;29 using HEAL.Attic; 30 30 31 31 namespace HeuristicLab.Problems.DataAnalysis { … … 33 33 /// Represents a classification solution that uses a discriminant function and classification thresholds. 34 34 /// </summary> 35 [Storable Class]35 [StorableType("3668EBE0-128C-4BC4-902C-161670F98FAD")] 36 36 [Item("DiscriminantFunctionClassificationSolution", "Represents a classification solution that uses a discriminant function and classification thresholds.")] 37 37 public abstract class DiscriminantFunctionClassificationSolutionBase : ClassificationSolutionBase, IDiscriminantFunctionClassificationSolution { … … 74 74 75 75 [StorableConstructor] 76 protected DiscriminantFunctionClassificationSolutionBase( bool deserializing) : base(deserializing) { }76 protected DiscriminantFunctionClassificationSolutionBase(StorableConstructorFlag _) : base(_) { } 77 77 protected DiscriminantFunctionClassificationSolutionBase(DiscriminantFunctionClassificationSolutionBase original, Cloner cloner) 78 78 : base(original, cloner) { -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ThresholdCalculators/AccuracyMaximizationThresholdCalculator.cs
r15866 r17980 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 25 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;27 using HEAL.Attic; 28 28 29 29 namespace HeuristicLab.Problems.DataAnalysis { … … 31 31 /// Represents a threshold calculator that maximizes the weighted accuracy of the classifcation model. 32 32 /// </summary> 33 [Storable Class]33 [StorableType("30BB9513-542D-4CB8-931B-9767C9CB2EFB")] 34 34 [Item("AccuracyMaximizationThresholdCalculator", "Represents a threshold calculator that maximizes the weighted accuracy of the classifcation model.")] 35 35 public class AccuracyMaximizationThresholdCalculator : ThresholdCalculator { 36 36 37 37 [StorableConstructor] 38 protected AccuracyMaximizationThresholdCalculator( bool deserializing) : base(deserializing) { }38 protected AccuracyMaximizationThresholdCalculator(StorableConstructorFlag _) : base(_) { } 39 39 protected AccuracyMaximizationThresholdCalculator(AccuracyMaximizationThresholdCalculator original, Cloner cloner) 40 40 : base(original, cloner) { -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ThresholdCalculators/NormalDistributionCutPointsThresholdCalculator.cs
r15866 r17980 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 25 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;27 using HEAL.Attic; 28 28 29 29 namespace HeuristicLab.Problems.DataAnalysis { … … 31 31 /// Represents a threshold calculator that calculates thresholds as the cutting points between the estimated class distributions (assuming normally distributed class values). 32 32 /// </summary> 33 [Storable Class]33 [StorableType("D01CB5DC-606B-4CE9-B293-2D4D80A70BB8")] 34 34 [Item("NormalDistributionCutPointsThresholdCalculator", "Represents a threshold calculator that calculates thresholds as the cutting points between the estimated class distributions (assuming normally distributed class values).")] 35 35 public class NormalDistributionCutPointsThresholdCalculator : ThresholdCalculator { 36 36 37 37 [StorableConstructor] 38 protected NormalDistributionCutPointsThresholdCalculator( bool deserializing) : base(deserializing) { }38 protected NormalDistributionCutPointsThresholdCalculator(StorableConstructorFlag _) : base(_) { } 39 39 protected NormalDistributionCutPointsThresholdCalculator(NormalDistributionCutPointsThresholdCalculator original, Cloner cloner) 40 40 : base(original, cloner) { -
branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ThresholdCalculators/ThresholdCalculator.cs
r15866 r17980 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;25 using HEAL.Attic; 26 26 27 27 namespace HeuristicLab.Problems.DataAnalysis { … … 29 29 /// Base class for threshold calculators for discriminant function classification models. 30 30 /// </summary> 31 [Storable Class]31 [StorableType("F56CDC6C-D4F5-4B2D-A7C4-04E0D2255699")] 32 32 public abstract class ThresholdCalculator : NamedItem, IDiscriminantFunctionThresholdCalculator { 33 33 34 34 [StorableConstructor] 35 protected ThresholdCalculator( bool deserializing) : base(deserializing) { }35 protected ThresholdCalculator(StorableConstructorFlag _) : base(_) { } 36 36 protected ThresholdCalculator(ThresholdCalculator original, Cloner cloner) 37 37 : base(original, cloner) {
Note: See TracChangeset
for help on using the changeset viewer.