- Timestamp:
- 03/17/15 15:56:40 (10 years ago)
- Location:
- branches/SensitivityEvaluator/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SensitivityEvaluator/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/Interfaces/ISymbolicDiscriminantFunctionClassificationModel.cs
r12012 r12216 20 20 #endregion 21 21 22 using System.Collections.Generic; 23 22 24 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification { 23 25 public interface ISymbolicDiscriminantFunctionClassificationModel : IDiscriminantFunctionClassificationModel, ISymbolicClassificationModel { 24 26 IEnumerable<double> GetEstimatedClassValues(IEnumerable<double> estimatedValues); 25 27 } 26 28 } -
branches/SensitivityEvaluator/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectiveWeightedPerformanceMeasuresEvaluator.cs
r12211 r12216 30 30 31 31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.SingleObjective { 32 [Item("Weighted Performance Measures Evaluator", "Calculates the quality a symbolic classification solution based on three weighted measures(normalized mean squared error, false negative rate and false positve rate).")]32 [Item("Weighted Performance Measures Evaluator", "Calculates the quality of a symbolic classification solution based on three weighted measures(normalized mean squared error, false negative rate(1-sensitivity) and false positve rate(1-specificity)).")] 33 33 [StorableClass] 34 34 public class SymbolicClassificationSingleObjectiveWeightedPerformanceMeasuresEvaluator : SymbolicClassificationSingleObjectiveEvaluator { … … 101 101 IEnumerable<int> rows, bool applyLinearScaling, ISymbolicClassificationModelCreator modelCreator, double normalizedMeanSquaredErrorWeightingFactor, double falseNegativeRateWeightingFactor, double falsePositiveRateWeightingFactor) { 102 102 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 103 IEnumerable<double> target Values = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);103 IEnumerable<double> targetClassValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 104 104 OnlineCalculatorError errorState; 105 105 double nmse; 106 106 107 107 //calculate performance measures 108 var model = modelCreator.CreateSymbolicClassificationModel(solution, interpreter, lowerEstimationLimit, upperEstimationLimit);108 var model = (ISymbolicDiscriminantFunctionClassificationModel)modelCreator.CreateSymbolicClassificationModel(solution, interpreter, lowerEstimationLimit, upperEstimationLimit); 109 109 string positiveClassName = problemData.PositiveClass; 110 model.RecalculateModelParameters(problemData, rows); 110 double[] classValues, thresholds; 111 model.ThresholdCalculator.Calculate(problemData, estimatedValues, targetClassValues, out classValues, out thresholds); 112 model.SetThresholdsAndClassValues(thresholds, classValues); 111 113 var performanceCalculator = new ClassificationPerformanceMeasuresCalculator(positiveClassName, problemData.GetClassValue(positiveClassName)); 112 var estimatedClassValues = model.GetEstimatedClassValues( problemData.Dataset, rows);113 performanceCalculator.Calculate( estimatedClassValues, targetValues);114 var estimatedClassValues = model.GetEstimatedClassValues(estimatedValues); 115 performanceCalculator.Calculate(targetClassValues, estimatedClassValues); 114 116 if (performanceCalculator.ErrorState != OnlineCalculatorError.None) 115 117 return Double.NaN; … … 119 121 if (applyLinearScaling) { 120 122 var nmseCalculator = new OnlineNormalizedMeanSquaredErrorCalculator(); 121 CalculateWithScaling(target Values, estimatedValues, lowerEstimationLimit, upperEstimationLimit, nmseCalculator, problemData.Dataset.Rows);123 CalculateWithScaling(targetClassValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, nmseCalculator, problemData.Dataset.Rows); 122 124 errorState = nmseCalculator.ErrorState; 123 125 nmse = nmseCalculator.NormalizedMeanSquaredError; 124 126 } else { 125 127 IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit); 126 nmse = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(target Values, boundedEstimatedValues, out errorState);128 nmse = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(targetClassValues, boundedEstimatedValues, out errorState); 127 129 } 128 130 if (errorState != OnlineCalculatorError.None) return Double.NaN; -
branches/SensitivityEvaluator/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicDiscriminantFunctionClassificationModel.cs
r12012 r12216 123 123 } 124 124 } 125 125 public IEnumerable<double> GetEstimatedClassValues(IEnumerable<double> estimatedValues) { 126 if (!Thresholds.Any() && !ClassValues.Any()) throw new ArgumentException("No thresholds and class values were set for the current symbolic classification model."); 127 foreach (var x in estimatedValues) { 128 int classIndex = 0; 129 // find first threshold value which is larger than x => class index = threshold index + 1 130 for (int i = 0; i < thresholds.Length; i++) { 131 if (x > thresholds[i]) classIndex++; 132 else break; 133 } 134 yield return classValues.ElementAt(classIndex - 1); 135 } 136 } 126 137 127 138 public override ISymbolicClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
Note: See TracChangeset
for help on using the changeset viewer.