Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/10/21 09:48:16 (4 years ago)
Author:
jzenisek
Message:

#2719 merged head of HeuristicLab.Problems.DataAnalysis into branch; added several minor items

Location:
branches/2719_HeuristicLab.DatastreamAnalysis
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • branches/2719_HeuristicLab.DatastreamAnalysis

  • branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis

  • branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleModel.cs

    r15866 r17980  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2424using HeuristicLab.Common;
    2525using HeuristicLab.Core;
    26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     26using HEAL.Attic;
    2727
    2828namespace HeuristicLab.Problems.DataAnalysis {
     
    3030  /// Represents classification solutions that contain an ensemble of multiple classification models
    3131  /// </summary>
    32   [StorableClass]
     32  [StorableType("0F720A40-5CC2-4E2B-8D4E-CCAD8EB56E43")]
    3333  [Item("ClassificationEnsembleModel", "A classification model that contains an ensemble of multiple classification models")]
    3434  public class ClassificationEnsembleModel : ClassificationModel, IClassificationEnsembleModel {
     
    4444
    4545    [StorableConstructor]
    46     protected ClassificationEnsembleModel(bool deserializing) : base(deserializing) { }
     46    protected ClassificationEnsembleModel(StorableConstructorFlag _) : base(_) { }
    4747    protected ClassificationEnsembleModel(ClassificationEnsembleModel original, Cloner cloner)
    4848      : base(original, cloner) {
  • branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleProblemData.cs

    r15866 r17980  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2525using HeuristicLab.Data;
    2626using HeuristicLab.Parameters;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HEAL.Attic;
    2828
    2929namespace HeuristicLab.Problems.DataAnalysis {
    30   [StorableClass]
     30  [StorableType("58768587-0920-4B52-95E4-66B54E8E837C")]
    3131  [Item("ClassificationEnsembleProblemData", "Represents an item containing all data defining a classification problem.")]
    3232  public class ClassificationEnsembleProblemData : ClassificationProblemData {
     
    6565
    6666    [StorableConstructor]
    67     protected ClassificationEnsembleProblemData(bool deserializing) : base(deserializing) { }
     67    protected ClassificationEnsembleProblemData(StorableConstructorFlag _) : base(_) { }
    6868    protected ClassificationEnsembleProblemData(ClassificationEnsembleProblemData original, Cloner cloner) : base(original, cloner) { }
    6969    public override IDeepCloneable Clone(Cloner cloner) {
  • branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleSolution.cs

    r15866 r17980  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2727using HeuristicLab.Core;
    2828using HeuristicLab.Data;
    29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29using HEAL.Attic;
    3030
    3131namespace HeuristicLab.Problems.DataAnalysis {
     
    3333  /// Represents classification solutions that contain an ensemble of multiple classification models
    3434  /// </summary>
    35   [StorableClass]
     35  [StorableType("4CDD22EE-B53D-4899-A77E-C503FF9EBC8E")]
    3636  [Item("Classification Ensemble Solution", "A classification solution that contains an ensemble of multiple classification models")]
    3737  [Creatable(CreatableAttribute.Categories.DataAnalysisEnsembles, Priority = 110)]
     
    6161
    6262    [StorableConstructor]
    63     private ClassificationEnsembleSolution(bool deserializing)
    64       : base(deserializing) {
     63    private ClassificationEnsembleSolution(StorableConstructorFlag _) : base(_) {
    6564      classificationSolutions = new ItemCollection<IClassificationSolution>();
    6665    }
  • branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationModel.cs

    r15866 r17980  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2424using HeuristicLab.Common;
    2525using HeuristicLab.Core;
    26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     26using HEAL.Attic;
    2727
    2828namespace HeuristicLab.Problems.DataAnalysis {
    29   [StorableClass]
     29  [StorableType("7E6091F9-86FD-4C47-8935-9C35CAB4261B")]
    3030  [Item("Classification Model", "Base class for all classification models.")]
    3131  public abstract class ClassificationModel : DataAnalysisModel, IClassificationModel {
     
    4141    }
    4242
    43     protected ClassificationModel(bool deserializing)
    44       : base(deserializing) {
     43    [StorableConstructor]
     44    protected ClassificationModel(StorableConstructorFlag _)
     45      : base(_) {
    4546      targetVariable = string.Empty;
    4647    }
     
    6667    public abstract IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData);
    6768
     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
    6897    #region events
    6998    public event EventHandler TargetVariableChanged;
  • branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationPerformanceMeasures.cs

    r15866 r17980  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2424using HeuristicLab.Data;
    2525using HeuristicLab.Optimization;
    26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     26using HEAL.Attic;
    2727
    2828namespace HeuristicLab.Problems.DataAnalysis {
    29   [StorableClass]
     29  [StorableType("6F44E140-22CF-48D3-B100-B6013F2B6608")]
    3030  public class ClassificationPerformanceMeasuresResultCollection : ResultCollection {
    3131    #region result names
     
    5454    }
    5555    [StorableConstructor]
    56     protected ClassificationPerformanceMeasuresResultCollection(bool deserializing)
    57       : base(deserializing) {
     56    protected ClassificationPerformanceMeasuresResultCollection(StorableConstructorFlag _) : base(_) {
    5857    }
    5958
  • branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblem.cs

    r15866 r17980  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     24using HEAL.Attic;
    2525
    2626namespace HeuristicLab.Problems.DataAnalysis {
    27   [StorableClass]
     27  [StorableType("93696570-A410-4885-A210-7220771B6050")]
    2828  [Item("Classification Problem", "A general classification problem.")]
    2929  public class ClassificationProblem : DataAnalysisProblem<IClassificationProblemData>, IClassificationProblem, IStorableContent {
     
    3131
    3232    [StorableConstructor]
    33     protected ClassificationProblem(bool deserializing) : base(deserializing) { }
     33    protected ClassificationProblem(StorableConstructorFlag _) : base(_) { }
    3434    protected ClassificationProblem(ClassificationProblem original, Cloner cloner) : base(original, cloner) { }
    3535    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  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2727using HeuristicLab.Data;
    2828using HeuristicLab.Parameters;
    29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29using HEAL.Attic;
    3030
    3131namespace HeuristicLab.Problems.DataAnalysis {
    32   [StorableClass]
     32  [StorableType("1C8DCCCF-4E2A-421D-9C61-7C017D584054")]
    3333  [Item("ClassificationProblemData", "Represents an item containing all data defining a classification problem.")]
    3434  public class ClassificationProblemData : DataAnalysisProblemData, IClassificationProblemData, IStorableContent {
     
    279279
    280280    [StorableConstructor]
    281     protected ClassificationProblemData(bool deserializing) : base(deserializing) { }
     281    protected ClassificationProblemData(StorableConstructorFlag _) : base(_) { }
    282282    [StorableHook(HookType.AfterDeserialization)]
    283283    private void AfterDeserialization() {
     
    467467    }
    468468    #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 targetVariable
    478       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     }
    518469  }
    519470}
  • branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolution.cs

    r15866 r17980  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2323using System.Linq;
    2424using HeuristicLab.Common;
    25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HEAL.Attic;
    2626
    2727namespace HeuristicLab.Problems.DataAnalysis {
     
    2929  /// Represents a classification data analysis solution
    3030  /// </summary>
    31   [StorableClass]
     31  [StorableType("A240D831-23D6-4432-A105-12D02D2EA75A")]
    3232  public class ClassificationSolution : ClassificationSolutionBase {
    3333    protected readonly Dictionary<int, double> evaluationCache;
    3434
    3535    [StorableConstructor]
    36     protected ClassificationSolution(bool deserializing)
    37       : base(deserializing) {
     36    protected ClassificationSolution(StorableConstructorFlag _) : base(_) {
    3837      evaluationCache = new Dictionary<int, double>();
    3938    }
  • branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolutionBase.cs

    r15866 r17980  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
     
    2526using HeuristicLab.Data;
    2627using HeuristicLab.Optimization;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     28using HEAL.Attic;
    2829using HeuristicLab.Problems.DataAnalysis.OnlineCalculators;
    2930
    3031namespace HeuristicLab.Problems.DataAnalysis {
    31   [StorableClass]
     32  [StorableType("60599497-EAF0-4DB0-B2E4-D58F34458D8F")]
    3233  public abstract class ClassificationSolutionBase : DataAnalysisSolution, IClassificationSolution {
    3334    private const string TrainingAccuracyResultName = "Accuracy (training)";
     
    4445    public new IClassificationProblemData ProblemData {
    4546      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      }
    4754    }
    4855
     
    7178
    7279    [StorableConstructor]
    73     protected ClassificationSolutionBase(bool deserializing) : base(deserializing) { }
     80    protected ClassificationSolutionBase(StorableConstructorFlag _) : base(_) { }
    7481    protected ClassificationSolutionBase(ClassificationSolutionBase original, Cloner cloner)
    7582      : base(original, cloner) {
  • branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolutionVariableImpactsCalculator.cs

    r15866 r17980  
    22
    33/* HeuristicLab
    4  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    55 *
    66 * This file is part of HeuristicLab.
     
    2323
    2424using System;
     25using System.Collections;
    2526using System.Collections.Generic;
    2627using System.Linq;
     
    2930using HeuristicLab.Data;
    3031using HeuristicLab.Parameters;
    31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     32using HEAL.Attic;
    3233using HeuristicLab.Random;
    3334
    3435namespace HeuristicLab.Problems.DataAnalysis {
    35   [StorableClass]
     36  [StorableType("768AFEDB-5641-429E-85A1-A0BE8DFDD56F")]
    3637  [Item("ClassificationSolution Impacts Calculator", "Calculation of the impacts of input variables for any classification solution")]
    3738  public sealed class ClassificationSolutionVariableImpactsCalculator : ParameterizedNamedItem {
     39    #region Parameters/Properties
     40    [StorableType("e6cd2226-10cd-4765-ae1a-924e316b6aac")]
    3841    public enum ReplacementMethodEnum {
    3942      Median,
     
    4245      Noise
    4346    }
     47
     48    [StorableType("84d84ccf-5d6d-432f-a946-eb499935e5c8")]
    4449    public enum FactorReplacementMethodEnum {
    4550      Best,
     
    4752      Shuffle
    4853    }
     54
     55    [StorableType("70f30113-df01-41b4-9e3b-2982035de498")]
    4956    public enum DataPartitionEnum {
    5057      Training,
     
    5461
    5562    private const string ReplacementParameterName = "Replacement Method";
     63    private const string FactorReplacementParameterName = "Factor Replacement Method";
    5664    private const string DataPartitionParameterName = "DataPartition";
    5765
    5866    public IFixedValueParameter<EnumValue<ReplacementMethodEnum>> ReplacementParameter {
    5967      get { return (IFixedValueParameter<EnumValue<ReplacementMethodEnum>>)Parameters[ReplacementParameterName]; }
     68    }
     69    public IFixedValueParameter<EnumValue<FactorReplacementMethodEnum>> FactorReplacementParameter {
     70      get { return (IFixedValueParameter<EnumValue<FactorReplacementMethodEnum>>)Parameters[FactorReplacementParameterName]; }
    6071    }
    6172    public IFixedValueParameter<EnumValue<DataPartitionEnum>> DataPartitionParameter {
     
    6778      set { ReplacementParameter.Value.Value = value; }
    6879    }
     80    public FactorReplacementMethodEnum FactorReplacementMethod {
     81      get { return FactorReplacementParameter.Value.Value; }
     82      set { FactorReplacementParameter.Value.Value = value; }
     83    }
    6984    public DataPartitionEnum DataPartition {
    7085      get { return DataPartitionParameter.Value.Value; }
    7186      set { DataPartitionParameter.Value.Value = value; }
    7287    }
    73 
    74 
     88    #endregion
     89
     90    #region Ctor/Cloner
    7591    [StorableConstructor]
    76     private ClassificationSolutionVariableImpactsCalculator(bool deserializing) : base(deserializing) { }
     92    private ClassificationSolutionVariableImpactsCalculator(StorableConstructorFlag _) : base(_) { }
    7793    private ClassificationSolutionVariableImpactsCalculator(ClassificationSolutionVariableImpactsCalculator original, Cloner cloner)
    7894      : 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
    79102    public override IDeepCloneable Clone(Cloner cloner) {
    80103      return new ClassificationSolutionVariableImpactsCalculator(this, cloner);
    81104    }
    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
    88106
    89107    //mkommend: annoying name clash with static method, open to better naming suggestions
    90108    public IEnumerable<Tuple<string, double>> Calculate(IClassificationSolution solution) {
    91       return CalculateImpacts(solution, DataPartition, ReplacementMethod);
     109      return CalculateImpacts(solution, ReplacementMethod, FactorReplacementMethod, DataPartition);
    92110    }
    93111
    94112    public static IEnumerable<Tuple<string, double>> CalculateImpacts(
    95113      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,
    98190      FactorReplacementMethodEnum factorReplacementMethod = FactorReplacementMethodEnum.Best) {
    99191
    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;
    180213      double replacementValue;
    181       List<double> replacementValues;
    182       IRandom rand;
    183 
    184       switch (replacement) {
     214
     215      switch (replacementMethod) {
    185216        case ReplacementMethodEnum.Median:
    186217          replacementValue = rows.Select(r => originalValues[r]).Median();
    187           replacementValues = Enumerable.Repeat(replacementValue, dataset.Rows).ToList();
     218          replacementValues = Enumerable.Repeat(replacementValue, modifiableDataset.Rows).ToList();
    188219          break;
    189220        case ReplacementMethodEnum.Average:
    190221          replacementValue = rows.Select(r => originalValues[r]).Average();
    191           replacementValues = Enumerable.Repeat(replacementValue, dataset.Rows).ToList();
     222          replacementValues = Enumerable.Repeat(replacementValue, modifiableDataset.Rows).ToList();
    192223          break;
    193224        case ReplacementMethodEnum.Shuffle:
    194225          // new var has same empirical distribution but the relation to y is broken
    195           rand = new FastRandom(31415);
    196226          // 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();
    198228          // 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();
    200230          int i = 0;
    201231          // update column values
     
    207237          var avg = rows.Select(r => originalValues[r]).Average();
    208238          var stdDev = rows.Select(r => originalValues[r]).StandardDeviation();
    209           rand = new FastRandom(31415);
    210239          // 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();
    212241          // update column values
    213242          foreach (var r in rows) {
    214             replacementValues[r] = NormalDistributedRandom.NextDouble(rand, avg, stdDev);
     243            replacementValues[r] = NormalDistributedRandom.NextDouble(random, avg, stdDev);
    215244          }
    216245          break;
    217246
    218247        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;
    234281        case FactorReplacementMethodEnum.Mode:
    235282          var mostCommonValue = rows.Select(r => originalValues[r])
     
    237284            .OrderByDescending(g => g.Count())
    238285            .First().Key;
    239           replacementValues = Enumerable.Repeat(mostCommonValue, dataset.Rows).ToList();
     286          replacementValues = Enumerable.Repeat(mostCommonValue, modifiableDataset.Rows).ToList();
    240287          break;
    241288        case FactorReplacementMethodEnum.Shuffle:
    242289          // new var has same empirical distribution but the relation to y is broken
    243           rand = new FastRandom(31415);
    244290          // 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();
    246292          // 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();
    248294          int i = 0;
    249295          // update column values
     
    253299          break;
    254300        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
    265323      //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;
    280356    }
    281357  }
  • branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ConstantClassificationSolution.cs

    r15866 r17980  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     24using HEAL.Attic;
    2525
    2626namespace HeuristicLab.Problems.DataAnalysis {
    27   [StorableClass]
     27  [StorableType("D5A42FE7-D21B-48F7-A812-FE69724D0098")]
    2828  [Item(Name = "Constant Classification Solution", Description = "Represents a constant classification solution (model + data).")]
    2929  public class ConstantClassificationSolution : ClassificationSolution {
     
    3434
    3535    [StorableConstructor]
    36     protected ConstantClassificationSolution(bool deserializing) : base(deserializing) { }
     36    protected ConstantClassificationSolution(StorableConstructorFlag _) : base(_) { }
    3737    protected ConstantClassificationSolution(ConstantClassificationSolution original, Cloner cloner) : base(original, cloner) { }
    3838    public ConstantClassificationSolution(ConstantModel model, IClassificationProblemData problemData)
  • branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationModel.cs

    r15866 r17980  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    2929namespace HeuristicLab.Problems.DataAnalysis {
     
    3131  /// Represents discriminant function classification data analysis models.
    3232  /// </summary>
    33   [StorableClass]
     33  [StorableType("E7A8648D-C938-499F-A712-185542095708")]
    3434  [Item("DiscriminantFunctionClassificationModel", "Represents a classification model that uses a discriminant function and classification thresholds.")]
    3535  public class DiscriminantFunctionClassificationModel : ClassificationModel, IDiscriminantFunctionClassificationModel {
     
    6868
    6969    [StorableConstructor]
    70     protected DiscriminantFunctionClassificationModel(bool deserializing) : base(deserializing) { }
     70    protected DiscriminantFunctionClassificationModel(StorableConstructorFlag _) : base(_) { }
    7171    protected DiscriminantFunctionClassificationModel(DiscriminantFunctionClassificationModel original, Cloner cloner)
    7272      : base(original, cloner) {
     
    121121
    122122    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) {
    123128      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) {
    125130        int classIndex = 0;
    126131        // find first threshold value which is larger than x => class index = threshold index + 1
     
    132137      }
    133138    }
     139
    134140    #region events
    135141    public event EventHandler ThresholdsChanged;
  • branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolution.cs

    r15866 r17980  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2424using HeuristicLab.Common;
    2525using HeuristicLab.Core;
    26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     26using HEAL.Attic;
    2727
    2828namespace HeuristicLab.Problems.DataAnalysis {
     
    3030  /// Represents a classification solution that uses a discriminant function and classification thresholds.
    3131  /// </summary>
    32   [StorableClass]
     32  [StorableType("A3480DF9-49E7-4329-AD23-57B4441033C1")]
    3333  [Item("DiscriminantFunctionClassificationSolution", "Represents a classification solution that uses a discriminant function and classification thresholds.")]
    3434  public class DiscriminantFunctionClassificationSolution : DiscriminantFunctionClassificationSolutionBase {
     
    3737
    3838    [StorableConstructor]
    39     protected DiscriminantFunctionClassificationSolution(bool deserializing)
    40       : base(deserializing) {
     39    protected DiscriminantFunctionClassificationSolution(StorableConstructorFlag _) : base(_) {
    4140      valueEvaluationCache = new Dictionary<int, double>();
    4241      classValueEvaluationCache = new Dictionary<int, double>();
  • branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolutionBase.cs

    r15866 r17980  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2727using HeuristicLab.Data;
    2828using HeuristicLab.Optimization;
    29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29using HEAL.Attic;
    3030
    3131namespace HeuristicLab.Problems.DataAnalysis {
     
    3333  /// Represents a classification solution that uses a discriminant function and classification thresholds.
    3434  /// </summary>
    35   [StorableClass]
     35  [StorableType("3668EBE0-128C-4BC4-902C-161670F98FAD")]
    3636  [Item("DiscriminantFunctionClassificationSolution", "Represents a classification solution that uses a discriminant function and classification thresholds.")]
    3737  public abstract class DiscriminantFunctionClassificationSolutionBase : ClassificationSolutionBase, IDiscriminantFunctionClassificationSolution {
     
    7474
    7575    [StorableConstructor]
    76     protected DiscriminantFunctionClassificationSolutionBase(bool deserializing) : base(deserializing) { }
     76    protected DiscriminantFunctionClassificationSolutionBase(StorableConstructorFlag _) : base(_) { }
    7777    protected DiscriminantFunctionClassificationSolutionBase(DiscriminantFunctionClassificationSolutionBase original, Cloner cloner)
    7878      : base(original, cloner) {
  • branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ThresholdCalculators/AccuracyMaximizationThresholdCalculator.cs

    r15866 r17980  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HEAL.Attic;
    2828
    2929namespace HeuristicLab.Problems.DataAnalysis {
     
    3131  /// Represents a threshold calculator that maximizes the weighted accuracy of the classifcation model.
    3232  /// </summary>
    33   [StorableClass]
     33  [StorableType("30BB9513-542D-4CB8-931B-9767C9CB2EFB")]
    3434  [Item("AccuracyMaximizationThresholdCalculator", "Represents a threshold calculator that maximizes the weighted accuracy of the classifcation model.")]
    3535  public class AccuracyMaximizationThresholdCalculator : ThresholdCalculator {
    3636
    3737    [StorableConstructor]
    38     protected AccuracyMaximizationThresholdCalculator(bool deserializing) : base(deserializing) { }
     38    protected AccuracyMaximizationThresholdCalculator(StorableConstructorFlag _) : base(_) { }
    3939    protected AccuracyMaximizationThresholdCalculator(AccuracyMaximizationThresholdCalculator original, Cloner cloner)
    4040      : base(original, cloner) {
  • branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ThresholdCalculators/NormalDistributionCutPointsThresholdCalculator.cs

    r15866 r17980  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HEAL.Attic;
    2828
    2929namespace HeuristicLab.Problems.DataAnalysis {
     
    3131  /// Represents a threshold calculator that calculates thresholds as the cutting points between the estimated class distributions (assuming normally distributed class values).
    3232  /// </summary>
    33   [StorableClass]
     33  [StorableType("D01CB5DC-606B-4CE9-B293-2D4D80A70BB8")]
    3434  [Item("NormalDistributionCutPointsThresholdCalculator", "Represents a threshold calculator that calculates thresholds as the cutting points between the estimated class distributions (assuming normally distributed class values).")]
    3535  public class NormalDistributionCutPointsThresholdCalculator : ThresholdCalculator {
    3636
    3737    [StorableConstructor]
    38     protected NormalDistributionCutPointsThresholdCalculator(bool deserializing) : base(deserializing) { }
     38    protected NormalDistributionCutPointsThresholdCalculator(StorableConstructorFlag _) : base(_) { }
    3939    protected NormalDistributionCutPointsThresholdCalculator(NormalDistributionCutPointsThresholdCalculator original, Cloner cloner)
    4040      : base(original, cloner) {
  • branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ThresholdCalculators/ThresholdCalculator.cs

    r15866 r17980  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
    25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HEAL.Attic;
    2626
    2727namespace HeuristicLab.Problems.DataAnalysis {
     
    2929  /// Base class for threshold calculators for discriminant function classification models.
    3030  /// </summary>
    31   [StorableClass]
     31  [StorableType("F56CDC6C-D4F5-4B2D-A7C4-04E0D2255699")]
    3232  public abstract class ThresholdCalculator : NamedItem, IDiscriminantFunctionThresholdCalculator {
    3333
    3434    [StorableConstructor]
    35     protected ThresholdCalculator(bool deserializing) : base(deserializing) { }
     35    protected ThresholdCalculator(StorableConstructorFlag _) : base(_) { }
    3636    protected ThresholdCalculator(ThresholdCalculator original, Cloner cloner)
    3737      : base(original, cloner) {
Note: See TracChangeset for help on using the changeset viewer.