Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13098 for branches


Ignore:
Timestamp:
11/02/15 21:54:58 (9 years ago)
Author:
gkronber
Message:

#1998:

  • introduced new class ConstantModel (to merge ConstantRegressionModel, ConstantClassificationModel and ConstantTimeSeriesModel)
  • fixed copyright statements
  • tried to unify naming
  • added F1 score and Matthew's correlation to classification results collection
Location:
branches/ClassificationModelComparison
Files:
18 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/OneRClassificationModelView.Designer.cs

    r9135 r13098  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/OneRClassificationModelView.cs

    r9135 r13098  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2626
    2727namespace HeuristicLab.Algorithms.DataAnalysis.Views {
    28   [View("1R Classification Model")]
     28  [View("OneR Classification Model")]
    2929  [Content(typeof(OneRClassificationModel), IsDefaultView = true)]
    3030  public partial class OneRClassificationModelView : AsynchronousContentView {
  • branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/BaselineClassifiers/OneRClassificationModel.cs

    r13090 r13098  
    3030namespace HeuristicLab.Algorithms.DataAnalysis {
    3131  [StorableClass]
    32   [Item("1R Classification Model", "A model that uses intervals for one variable to determine the class.")]
     32  [Item("OneR Classification Model", "A model that uses intervals for one variable to determine the class.")]
    3333  public class OneRClassificationModel : NamedItem, IClassificationModel {
    3434    [Storable]
  • branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/BaselineClassifiers/OneRClassificationSolution.cs

    r13090 r13098  
    2727namespace HeuristicLab.Algorithms.DataAnalysis {
    2828  [StorableClass]
    29   [Item(Name = "1R Classification Solution", Description = "Represents a 1R classification solution (model + data).")]
     29  [Item(Name = "OneR Classification Solution", Description = "Represents a OneR classification solution which uses only a single feature with potentially multiple thresholds for class prediction.")]
    3030  public class OneRClassificationSolution : ClassificationSolution {
    3131    public new OneRClassificationModel Model {
  • branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/BaselineClassifiers/ZeroR.cs

    r13092 r13098  
    6464        .MaxItems(kvp => kvp.Value).Select(x => x.Key).First();
    6565
    66       var model = new ConstantRegressionModel(dominantClass);
    67       var solution = new ConstantClassificationSolution(model, (IClassificationProblemData)problemData.Clone());
     66      var model = new ConstantModel(dominantClass);
     67      var solution = model.CreateClassificationSolution(problemData);
    6868      return solution;
    6969    }
  • branches/ClassificationModelComparison/HeuristicLab.Algorithms.DataAnalysis/3.4/GradientBoostedTrees/GradientBoostedTreesAlgorithmStatic.cs

    r13065 r13098  
    9696        weights = new List<double>();
    9797        // add constant model
    98         models.Add(new ConstantRegressionModel(f0));
     98        models.Add(new ConstantModel(f0));
    9999        weights.Add(1.0);
    100100      }
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionComparisonView.Designer.cs

    r9135 r13098  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionComparisonView.cs

    r13091 r13098  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2727using HeuristicLab.MainForm;
    2828using HeuristicLab.Problems.DataAnalysis.OnlineCalculators;
    29 using HeuristicLab.Random;
    3029
    3130namespace HeuristicLab.Problems.DataAnalysis.Views.Classification {
    32   [View("Solution Comparions")]
     31  [View("Classification Solution Comparions")]
    3332  [Content(typeof(IClassificationSolution))]
    3433  public partial class ClassificationSolutionComparisonView : DataAnalysisSolutionEvaluationView {
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionErrorCharacteristicsCurveView.cs

    r13082 r13098  
    292292    private IRegressionSolution CreateConstantSolution() {
    293293      double averageTrainingTarget = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).Average();
    294       var model = new ConstantRegressionModel(averageTrainingTarget);
    295       var solution = new ConstantRegressionSolution(model, (IRegressionProblemData)ProblemData.Clone());
     294      var model = new ConstantModel(averageTrainingTarget);
     295      var solution = model.CreateRegressionSolution(ProblemData);
    296296      solution.Name = "Baseline (constant)";
    297297      return solution;
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj

    r13089 r13098  
    175175    <Compile Include="Implementation\Clustering\ClusteringProblemData.cs" />
    176176    <Compile Include="Implementation\Clustering\ClusteringSolution.cs" />
     177    <Compile Include="Implementation\Regression\ConstantModel.cs" />
    177178    <Compile Include="Implementation\Regression\ConstantRegressionModel.cs" />
    178179    <Compile Include="Implementation\Regression\ConstantRegressionSolution.cs" />
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationPerformanceMeasures.cs

    r13083 r13098  
    3737    protected const string TrainingFalsePositiveRateResultName = "False positive rate (training)";
    3838    protected const string TrainingFalseDiscoveryRateResultName = "False discovery rate (training)";
     39    protected const string TrainingF1ScoreResultName = "F1 score (training)";
     40    protected const string TrainingMatthewsCorrelationResultName = "Matthews Correlation (training)";
    3941    protected const string TestTruePositiveRateResultName = "True positive rate (test)";
    4042    protected const string TestTrueNegativeRateResultName = "True negative rate (test)";
     
    4345    protected const string TestFalsePositiveRateResultName = "False positive rate (test)";
    4446    protected const string TestFalseDiscoveryRateResultName = "False discovery rate (test)";
     47    protected const string TestF1ScoreResultName = "F1 score (test)";
     48    protected const string TestMatthewsCorrelationResultName = "Matthews Correlation (test)";
    4549    #endregion
    4650
     
    8993      set { ((DoubleValue)this[TrainingFalseDiscoveryRateResultName].Value).Value = value; }
    9094    }
     95    public double TrainingF1Score {
     96      get { return ((DoubleValue)this[TrainingF1ScoreResultName].Value).Value; }
     97      set { ((DoubleValue)this[TrainingF1ScoreResultName].Value).Value = value; }
     98    }
     99    public double TrainingMatthewsCorrelation {
     100      get { return ((DoubleValue)this[TrainingMatthewsCorrelationResultName].Value).Value; }
     101      set { ((DoubleValue)this[TrainingMatthewsCorrelationResultName].Value).Value = value; }
     102    }
    91103    public double TestTruePositiveRate {
    92104      get { return ((DoubleValue)this[TestTruePositiveRateResultName].Value).Value; }
     
    113125      set { ((DoubleValue)this[TestFalseDiscoveryRateResultName].Value).Value = value; }
    114126    }
     127    public double TestF1Score {
     128      get { return ((DoubleValue)this[TestF1ScoreResultName].Value).Value; }
     129      set { ((DoubleValue)this[TestF1ScoreResultName].Value).Value = value; }
     130    }
     131    public double TestMatthewsCorrelation {
     132      get { return ((DoubleValue)this[TestMatthewsCorrelationResultName].Value).Value; }
     133      set { ((DoubleValue)this[TestMatthewsCorrelationResultName].Value).Value = value; }
     134    }
    115135    #endregion
    116136
     
    122142      Add(new Result(TrainingNegativePredictiveValueResultName, "Negative predictive value of the model on the training partition\n(TN/(TN+FN)).", new PercentValue()));
    123143      Add(new Result(TrainingFalsePositiveRateResultName, "The false positive rate is the complement of the true negative rate of the model on the training partition.", new PercentValue()));
    124       Add(new Result(TrainingFalseDiscoveryRateResultName, "The false discovery rate is the complement of the positive predictive value of the model on the training partition.", new PercentValue()));
     144      Add(new Result(TrainingFalseDiscoveryRateResultName, "The false discovery rate is the complement of the positive predictive value of the model on the test partition.", new PercentValue()));
     145      Add(new Result(TrainingF1ScoreResultName, "The F1 score of the model on the training partition.", new DoubleValue()));
     146      Add(new Result(TrainingMatthewsCorrelationResultName, "The Matthew's correlation value of the model on the training partition.", new DoubleValue()));
    125147      Add(new Result(TestTruePositiveRateResultName, "Sensitivity/True positive rate of the model on the test partition\n(TP/(TP+FN)).", new PercentValue()));
    126148      Add(new Result(TestTrueNegativeRateResultName, "Specificity/True negative rate of the model on the test partition\n(TN/(FP+TN)).", new PercentValue()));
     
    129151      Add(new Result(TestFalsePositiveRateResultName, "The false positive rate is the complement of the true negative rate of the model on the test partition.", new PercentValue()));
    130152      Add(new Result(TestFalseDiscoveryRateResultName, "The false discovery rate is the complement of the positive predictive value of the model on the test partition.", new PercentValue()));
     153      Add(new Result(TestF1ScoreResultName, "The F1 score of the model on the test partition.", new DoubleValue()));
     154      Add(new Result(TrainingMatthewsCorrelationResultName, "The Matthew's correlation value of the model on the test partition.", new DoubleValue()));
    131155      TrainingTruePositiveRate = double.NaN;
    132156      TrainingTrueNegativeRate = double.NaN;
     
    135159      TrainingFalsePositiveRate = double.NaN;
    136160      TrainingFalseDiscoveryRate = double.NaN;
     161      TrainingF1Score = double.NaN;
     162      TrainingMatthewsCorrelation = double.NaN;
    137163      TestTruePositiveRate = double.NaN;
    138164      TestTrueNegativeRate = double.NaN;
     
    141167      TestFalsePositiveRate = double.NaN;
    142168      TestFalseDiscoveryRate = double.NaN;
     169      TestF1Score = double.NaN;
     170      TestMatthewsCorrelation = double.NaN;
    143171    }
    144172
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolutionBase.cs

    r13083 r13098  
    2626using HeuristicLab.Optimization;
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     28using HeuristicLab.Problems.DataAnalysis.OnlineCalculators;
    2829
    2930namespace HeuristicLab.Problems.DataAnalysis {
     
    135136      if (testPerformanceCalculator.ErrorState == OnlineCalculatorError.None)
    136137        ClassificationPerformanceMeasures.SetTestResults(testPerformanceCalculator);
     138
     139      var f1Training = FOneScoreCalculator.Calculate(originalTrainingClassValues, estimatedTrainingClassValues, out errorState);
     140      if (errorState == OnlineCalculatorError.None) ClassificationPerformanceMeasures.TrainingF1Score = f1Training;
     141      var f1Test = FOneScoreCalculator.Calculate(originalTestClassValues, estimatedTestClassValues, out errorState);
     142      if (errorState == OnlineCalculatorError.None) ClassificationPerformanceMeasures.TestF1Score = f1Test;
     143
     144
     145      var mccTraining = MatthewsCorrelationCoefficientCalculator.Calculate(originalTrainingClassValues, estimatedTrainingClassValues, out errorState);
     146      if (errorState == OnlineCalculatorError.None) ClassificationPerformanceMeasures.TrainingMatthewsCorrelation = mccTraining;
     147      var mccTest = MatthewsCorrelationCoefficientCalculator.Calculate(originalTestClassValues, estimatedTestClassValues, out errorState);
     148      if (errorState == OnlineCalculatorError.None) ClassificationPerformanceMeasures.TestMatthewsCorrelation = mccTest;
    137149    }
    138150
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ConstantClassificationSolution.cs

    r13089 r13098  
    2828  [Item(Name = "Constant Classification Solution", Description = "Represents a constant classification solution (model + data).")]
    2929  public class ConstantClassificationSolution : ClassificationSolution {
    30     public new ConstantRegressionModel Model {
    31       get { return (ConstantRegressionModel)base.Model; }
     30    public new ConstantModel Model {
     31      get { return (ConstantModel)base.Model; }
    3232      set { base.Model = value; }
    3333    }
     
    3636    protected ConstantClassificationSolution(bool deserializing) : base(deserializing) { }
    3737    protected ConstantClassificationSolution(ConstantClassificationSolution original, Cloner cloner) : base(original, cloner) { }
    38     public ConstantClassificationSolution(ConstantRegressionModel model, IClassificationProblemData problemData)
     38    public ConstantClassificationSolution(ConstantModel model, IClassificationProblemData problemData)
    3939      : base(model, problemData) {
    4040      RecalculateResults();
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/ConstantModel.cs

    r13097 r13098  
    3030namespace HeuristicLab.Problems.DataAnalysis {
    3131  [StorableClass]
    32   [Item("Constant Regression Model", "A model that always returns the same constant value regardless of the presented input data.")]
    33   public class ConstantRegressionModel : NamedItem, IRegressionModel, IStringConvertibleValue {
     32  [Item("Constant Model", "A model that always returns the same constant value regardless of the presented input data.")]
     33  public class ConstantModel : NamedItem, IRegressionModel, IClassificationModel, ITimeSeriesPrognosisModel, IStringConvertibleValue {
    3434    [Storable]
    3535    private double constant;
     
    4040
    4141    [StorableConstructor]
    42     protected ConstantRegressionModel(bool deserializing) : base(deserializing) { }
    43     protected ConstantRegressionModel(ConstantRegressionModel original, Cloner cloner)
     42    protected ConstantModel(bool deserializing) : base(deserializing) { }
     43    protected ConstantModel(ConstantModel original, Cloner cloner)
    4444      : base(original, cloner) {
    4545      this.constant = original.constant;
    4646    }
    47     public override IDeepCloneable Clone(Cloner cloner) { return new ConstantRegressionModel(this, cloner); }
     47    public override IDeepCloneable Clone(Cloner cloner) { return new ConstantModel(this, cloner); }
    4848
    49     public ConstantRegressionModel(double constant)
     49    public ConstantModel(double constant)
    5050      : base() {
    5151      this.name = ItemName;
     
    5858      return rows.Select(row => Constant);
    5959    }
     60    public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {
     61      return GetEstimatedValues(dataset, rows);
     62    }
     63    public IEnumerable<IEnumerable<double>> GetPrognosedValues(IDataset dataset, IEnumerable<int> rows, IEnumerable<int> horizons) {
     64      return rows.Select(_ => horizons.Select(__ => Constant));
     65    }
    6066
    6167    public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
    6268      return new ConstantRegressionSolution(this, new RegressionProblemData(problemData));
     69    }
     70    public IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
     71      return new ConstantClassificationSolution(this, new ClassificationProblemData(problemData));
     72    }
     73    public ITimeSeriesPrognosisSolution CreateTimeSeriesPrognosisSolution(ITimeSeriesPrognosisProblemData problemData) {
     74      return new TimeSeriesPrognosisSolution(this, new TimeSeriesPrognosisProblemData(problemData));
    6375    }
    6476
     
    8395    public event EventHandler ValueChanged;
    8496    #endregion
     97
    8598  }
    8699}
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/ConstantRegressionModel.cs

    r13097 r13098  
    3131  [StorableClass]
    3232  [Item("Constant Regression Model", "A model that always returns the same constant value regardless of the presented input data.")]
     33  [Obsolete]
    3334  public class ConstantRegressionModel : NamedItem, IRegressionModel, IStringConvertibleValue {
    3435    [Storable]
     
    6061
    6162    public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
    62       return new ConstantRegressionSolution(this, new RegressionProblemData(problemData));
     63      return new ConstantRegressionSolution(new ConstantModel(constant), new RegressionProblemData(problemData));
    6364    }
    6465
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/ConstantRegressionSolution.cs

    r13083 r13098  
    2828  [Item(Name = "Constant Regression Solution", Description = "Represents a constant regression solution (model + data).")]
    2929  public class ConstantRegressionSolution : RegressionSolution {
    30     public new ConstantRegressionModel Model {
    31       get { return (ConstantRegressionModel)base.Model; }
     30    public new ConstantModel Model {
     31      get { return (ConstantModel)base.Model; }
    3232      set { base.Model = value; }
    3333    }
     
    3636    protected ConstantRegressionSolution(bool deserializing) : base(deserializing) { }
    3737    protected ConstantRegressionSolution(ConstantRegressionSolution original, Cloner cloner) : base(original, cloner) { }
    38     public ConstantRegressionSolution(ConstantRegressionModel model, IRegressionProblemData problemData)
     38    public ConstantRegressionSolution(ConstantModel model, IRegressionProblemData problemData)
    3939      : base(model, problemData) {
    4040      RecalculateResults();
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/Models/ConstantTimeSeriesPrognosisModel.cs

    r13083 r13098  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
     
    2930  [StorableClass]
    3031  [Item("Constant TimeSeries Model", "A time series model that returns for all prediciton the same constant value.")]
     32  [Obsolete]
    3133  public class ConstantTimeSeriesPrognosisModel : ConstantRegressionModel, ITimeSeriesPrognosisModel {
    3234    [StorableConstructor]
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisResults.cs

    r13083 r13098  
    373373      //mean model
    374374      double trainingMean = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TrainingIndices).Average();
    375       var meanModel = new ConstantTimeSeriesPrognosisModel(trainingMean);
     375      var meanModel = new ConstantModel(trainingMean);
    376376
    377377      //AR1 model
     
    448448        //mean model
    449449        double trainingMean = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TrainingIndices).Average();
    450         var meanModel = new ConstantTimeSeriesPrognosisModel(trainingMean);
     450        var meanModel = new ConstantModel(trainingMean);
    451451
    452452        //AR1 model
  • branches/ClassificationModelComparison/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisSolutionBase.cs

    r13083 r13098  
    150150      OnlineCalculatorError errorState;
    151151      double trainingMean = ProblemData.TrainingIndices.Any() ? ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).Average() : double.NaN;
    152       var meanModel = new ConstantTimeSeriesPrognosisModel(trainingMean);
     152      var meanModel = new ConstantModel(trainingMean);
    153153
    154154      double alpha, beta;
Note: See TracChangeset for help on using the changeset viewer.