Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/15/15 13:48:00 (10 years ago)
Author:
mkommend
Message:

#2278: Renamed positive class parameter to satisfy the parameter visibility unit test and fixed cloning of classification performance measures.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationPerformanceMeasures.cs

    r11763 r11766  
    2121
    2222using System;
     23using HeuristicLab.Common;
    2324using HeuristicLab.Data;
    2425using HeuristicLab.Optimization;
     
    5152    protected ClassificationPerformanceMeasuresResultCollection(bool deserializing)
    5253      : base(deserializing) {
     54    }
     55
     56    protected ClassificationPerformanceMeasuresResultCollection(ClassificationPerformanceMeasuresResultCollection original, Cloner cloner)
     57      : base(original, cloner) { }
     58    public override IDeepCloneable Clone(Cloner cloner) {
     59      return new ClassificationPerformanceMeasuresResultCollection(this, cloner);
    5360    }
    5461
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblemData.cs

    r11763 r11766  
    3636    protected const string ClassNamesParameterName = "ClassNames";
    3737    protected const string ClassificationPenaltiesParameterName = "ClassificationPenalties";
    38     protected const string PositiveClassNameParameterName = "PositiveClass";
     38    protected const string PositiveClassParameterName = "PositiveClass";
    3939    protected const int MaximumNumberOfClasses = 100;
    4040    protected const int InspectedRowsToDetermineTargets = 2000;
     
    214214      get { return (IFixedValueParameter<StringMatrix>)Parameters[ClassNamesParameterName]; }
    215215    }
    216     public IConstrainedValueParameter<StringValue> PositiveClassNameParameter {
    217       get { return (IConstrainedValueParameter<StringValue>)Parameters[PositiveClassNameParameterName]; }
     216    public IConstrainedValueParameter<StringValue> PositiveClassParameter {
     217      get { return (IConstrainedValueParameter<StringValue>)Parameters[PositiveClassParameterName]; }
    218218    }
    219219    public IFixedValueParameter<DoubleMatrix> ClassificationPenaltiesParameter {
     
    267267    }
    268268
    269     public string PositiveClassName {
    270       get { return PositiveClassNameParameter.Value.Value; }
     269    public string PositiveClass {
     270      get { return PositiveClassParameter.Value.Value; }
    271271      set {
    272         var matchingValue = PositiveClassNameParameter.ValidValues.SingleOrDefault(x => x.Value == value);
     272        var matchingValue = PositiveClassParameter.ValidValues.SingleOrDefault(x => x.Value == value);
    273273        if (matchingValue == null) throw new ArgumentException(string.Format("{0} cannot be set as positive class.", value));
    274         PositiveClassNameParameter.Value = matchingValue;
     274        PositiveClassParameter.Value = matchingValue;
    275275      }
    276276    }
     
    285285      // BackwardsCompatibility3.4
    286286      #region Backwards compatible code, remove with 3.5
    287       if (!Parameters.ContainsKey(PositiveClassNameParameterName)) {
     287      if (!Parameters.ContainsKey(PositiveClassParameterName)) {
    288288        var validValues = new ItemSet<StringValue>(ClassNames.Select(s => new StringValue(s).AsReadOnly()));
    289         Parameters.Add(new ConstrainedValueParameter<StringValue>(PositiveClassNameParameterName,
     289        Parameters.Add(new ConstrainedValueParameter<StringValue>(PositiveClassParameterName,
    290290          "The positive class which is used for quality measure calculation (e.g., specifity, sensitivity,...)", validValues, validValues.First()));
    291291      }
     
    329329      Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>(validTargetVariableValues), target));
    330330      Parameters.Add(new FixedValueParameter<StringMatrix>(ClassNamesParameterName, ""));
    331       Parameters.Add(new ConstrainedValueParameter<StringValue>(PositiveClassNameParameterName, "The positive class which is used for quality measure calculation (e.g., specifity, sensitivity,...)"));
     331      Parameters.Add(new ConstrainedValueParameter<StringValue>(PositiveClassParameterName, "The positive class which is used for quality measure calculation (e.g., specifity, sensitivity,...)"));
    332332      Parameters.Add(new FixedValueParameter<DoubleMatrix>(ClassificationPenaltiesParameterName, ""));
    333333
     
    363363      ClassNamesParameter.Value.RowNames = ClassValues.Select(s => "ClassValue: " + s);
    364364
    365       PositiveClassNameParameter.ValidValues.Clear();
     365      PositiveClassParameter.ValidValues.Clear();
    366366      foreach (var className in ClassNames) {
    367         PositiveClassNameParameter.ValidValues.Add(new StringValue(className).AsReadOnly());
     367        PositiveClassParameter.ValidValues.Add(new StringValue(className).AsReadOnly());
    368368      }
    369369
     
    439439    }
    440440    private void Parameter_ValueChanged(object sender, EventArgs e) {
    441       var oldPositiveClass = PositiveClassName;
     441      var oldPositiveClass = PositiveClass;
    442442      var oldClassNames = classNamesCache;
    443443      var index = oldClassNames.IndexOf(oldPositiveClass);
     
    447447      ClassificationPenaltiesParameter.Value.ColumnNames = ClassNames.Select(name => "Estimated " + name);
    448448
    449       PositiveClassNameParameter.ValidValues.Clear();
     449      PositiveClassParameter.ValidValues.Clear();
    450450      foreach (var className in ClassNames) {
    451         PositiveClassNameParameter.ValidValues.Add(new StringValue(className).AsReadOnly());
    452       }
    453       PositiveClassNameParameter.Value = PositiveClassNameParameter.ValidValues.ElementAt(index);
     451        PositiveClassParameter.ValidValues.Add(new StringValue(className).AsReadOnly());
     452      }
     453      PositiveClassParameter.Value = PositiveClassParameter.ValidValues.ElementAt(index);
    454454
    455455      OnChanged();
     
    477477      }
    478478
    479       var newPositivieClassName = classificationProblemData.PositiveClassName;
    480       if (newPositivieClassName != PositiveClassName) {
     479      var newPositivieClassName = classificationProblemData.PositiveClass;
     480      if (newPositivieClassName != PositiveClass) {
    481481        errorMessage = errorMessage + string.Format("The positive class differs in the provided classification problem data.");
    482482        returnValue = false;
     
    497497        ClassNamesParameter.Value[i, 0] = classificationProblemData.ClassNames.ElementAt(i);
    498498
    499       PositiveClassName = classificationProblemData.PositiveClassName;
     499      PositiveClass = classificationProblemData.PositiveClass;
    500500
    501501      for (int i = 0; i < Classes; i++) {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolutionBase.cs

    r11763 r11766  
    9595                              In a multiclass classification all misclassifications of the negative class will be treated as true negatives except on positive class estimations.",
    9696                              new ClassificationPerformanceMeasuresResultCollection()));
    97         RecalculateResults();
     97        CalculateClassificationResults();
    9898      }
    9999    }
     
    106106      double[] originalTestClassValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TestIndices).ToArray();
    107107
    108       var positiveClassName = ProblemData.PositiveClassName;
     108      var positiveClassName = ProblemData.PositiveClass;
    109109      double positiveClassValue = ProblemData.GetClassValue(positiveClassName);
    110110      ClassificationPerformanceMeasuresCalculator trainingPerformanceCalculator = new ClassificationPerformanceMeasuresCalculator(positiveClassName, positiveClassValue);
Note: See TracChangeset for help on using the changeset viewer.