Changeset 18027 for branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolutionBase.cs
- Timestamp:
- 07/20/21 18:13:55 (3 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis merged: 17931,17937,17958,17960-17964,17981-17982,17999-18000
- Property svn:mergeinfo changed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis/3.4
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis/3.4 merged: 17931,17937,17958,17960-17964,17981-17982,17999-18000
- Property svn:mergeinfo changed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolutionBase.cs
r17180 r18027 40 40 private const string TrainingRSquaredResultName = "Pearson's R² (training)"; 41 41 private const string TestRSquaredResultName = "Pearson's R² (test)"; 42 private const string TrainingNormalizedGiniCoefficientResultName = "Norm. Gini coeff. (training, discriminant values)"; 43 private const string TestNormalizedGiniCoefficientResultName = "Norm. Gini coeff. (test, discriminant values)"; 44 42 45 43 46 public new IDiscriminantFunctionClassificationModel Model { … … 71 74 private set { ((DoubleValue)this[TestRSquaredResultName].Value).Value = value; } 72 75 } 76 public double TrainingNormalizedGiniCoefficientForDiscriminantValues { 77 get { return ((DoubleValue)this[TrainingNormalizedGiniCoefficientResultName].Value).Value; } 78 protected set { ((DoubleValue)this[TrainingNormalizedGiniCoefficientResultName].Value).Value = value; } 79 } 80 public double TestNormalizedGiniCoefficientForDiscriminantValues { 81 get { return ((DoubleValue)this[TestNormalizedGiniCoefficientResultName].Value).Value; } 82 protected set { ((DoubleValue)this[TestNormalizedGiniCoefficientResultName].Value).Value = value; } 83 } 73 84 #endregion 74 85 … … 85 96 Add(new Result(TrainingRSquaredResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the training partition", new DoubleValue())); 86 97 Add(new Result(TestRSquaredResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the test partition", new DoubleValue())); 98 Add(new Result(TrainingNormalizedGiniCoefficientResultName, "Normalized Gini coefficient of the discriminant values produced by the model on the training partition.", new DoubleValue())); 99 Add(new Result(TestNormalizedGiniCoefficientResultName, "Normalized Gini coefficient of the discriminant values produced by the model on the test partition.", new DoubleValue())); 87 100 RegisterEventHandler(); 88 101 } … … 90 103 [StorableHook(HookType.AfterDeserialization)] 91 104 private void AfterDeserialization() { 105 #region backwards compatibility 106 if (!ContainsKey(TrainingNormalizedGiniCoefficientResultName)) { 107 Add(new Result(TrainingNormalizedGiniCoefficientResultName, "Normalized Gini coefficient of the discriminant values produced by the model on the training partition.", new DoubleValue())); 108 Add(new Result(TestNormalizedGiniCoefficientResultName, "Normalized Gini coefficient of the discriminant values produced by the model on the test partition.", new DoubleValue())); 109 double[] estimatedTrainingValues = EstimatedTrainingValues.ToArray(); // cache values 110 double[] originalTrainingValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).ToArray(); 111 double[] estimatedTestValues = EstimatedTestValues.ToArray(); // cache values 112 double[] originalTestValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TestIndices).ToArray(); 113 double trainingNormalizedGini = NormalizedGiniCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out var errorState); 114 if (errorState != OnlineCalculatorError.None) trainingNormalizedGini = double.NaN; 115 double testNormalizedGini = NormalizedGiniCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState); 116 if (errorState != OnlineCalculatorError.None) testNormalizedGini = double.NaN; 117 118 TrainingNormalizedGiniCoefficientForDiscriminantValues = trainingNormalizedGini; 119 TestNormalizedGiniCoefficientForDiscriminantValues = testNormalizedGini; 120 } 121 #endregion 92 122 RegisterEventHandler(); 93 123 } … … 106 136 107 137 double trainingR = OnlinePearsonsRCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState); 108 TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR *trainingR : double.NaN;138 TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR * trainingR : double.NaN; 109 139 double testR = OnlinePearsonsRCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState); 110 TestRSquared = errorState == OnlineCalculatorError.None ? testR *testR : double.NaN;140 TestRSquared = errorState == OnlineCalculatorError.None ? testR * testR : double.NaN; 111 141 112 142 double trainingNormalizedGini = NormalizedGiniCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState); … … 115 145 if (errorState != OnlineCalculatorError.None) testNormalizedGini = double.NaN; 116 146 117 TrainingNormalizedGiniCoefficient = trainingNormalizedGini;118 TestNormalizedGiniCoefficient = testNormalizedGini;147 TrainingNormalizedGiniCoefficientForDiscriminantValues = trainingNormalizedGini; 148 TestNormalizedGiniCoefficientForDiscriminantValues = testNormalizedGini; 119 149 } 120 150
Note: See TracChangeset
for help on using the changeset viewer.