Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/17/11 15:14:45 (13 years ago)
Author:
gkronber
Message:

#1418 implemented linear scaling for classification solutions, fixed bugs interactive simplifier view for classification solutions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationModel.cs

    r5730 r5736  
    4040    [Storable]
    4141    private IRegressionModel model;
     42
    4243    [Storable]
    4344    private double[] classValues;
    44     // class values are not necessarily sorted in ascending order
    4545    public IEnumerable<double> ClassValues {
    4646      get { return (double[])classValues.Clone(); }
    47       set {
    48         if (value == null) throw new ArgumentException();
    49         double[] newValue = value.ToArray();
    50         if (newValue.Length != classValues.Length) throw new ArgumentException();
    51         classValues = newValue;
    52       }
     47      private set { classValues = value.ToArray(); }
    5348    }
     49
    5450    [Storable]
    5551    private double[] thresholds;
    5652    public IEnumerable<double> Thresholds {
    5753      get { return (IEnumerable<double>)thresholds.Clone(); }
    58       set {
    59         thresholds = value.ToArray();
    60         OnThresholdsChanged(EventArgs.Empty);
    61       }
     54      private set { thresholds = value.ToArray(); }
    6255    }
    6356
     
    7164      thresholds = (double[])original.thresholds.Clone();
    7265    }
    73     public DiscriminantFunctionClassificationModel(IRegressionModel model, IEnumerable<double> classValues, IEnumerable<double> thresholds)
     66
     67    public DiscriminantFunctionClassificationModel(IRegressionModel model)
    7468      : base() {
    7569      this.name = ItemName;
    7670      this.description = ItemDescription;
    7771      this.model = model;
    78       this.classValues = classValues.ToArray();
    79       this.thresholds = thresholds.ToArray();
     72      this.classValues = new double[] { 0.0 };
     73      this.thresholds = new double[] { double.NegativeInfinity };
    8074    }
    8175
    8276    public override IDeepCloneable Clone(Cloner cloner) {
    8377      return new DiscriminantFunctionClassificationModel(this, cloner);
     78    }
     79
     80    public void SetThresholdsAndClassValues(IEnumerable<double> thresholds, IEnumerable<double> classValues) {
     81      var classValuesArr = classValues.ToArray();
     82      var thresholdsArr = thresholds.ToArray();
     83      if (thresholdsArr.Length != classValuesArr.Length) throw new ArgumentException();
     84
     85      this.classValues = classValuesArr;
     86      this.thresholds = thresholdsArr;
     87      OnThresholdsChanged(EventArgs.Empty);
    8488    }
    8589
     
    96100          else break;
    97101        }
    98         yield return classValues.ElementAt(classIndex);
     102        yield return classValues.ElementAt(classIndex - 1);
    99103      }
    100104    }
Note: See TracChangeset for help on using the changeset viewer.