Changeset 12448 for branches/SensitivityEvaluator/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective
- Timestamp:
- 06/15/15 17:00:37 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SensitivityEvaluator/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectiveWeightedResidualsMeanSquaredErrorEvaluator.cs
r12416 r12448 32 32 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification { 33 33 [Item("Weighted Residuals Mean Squared Error Evaluator", @"A modified mean squared error evaluator that enables the possibility to weight residuals differently. 34 The first residual category belongs to estimated values which obviously belong to a specific class because the estimated value is located above the maximum or below the minimum of all the class values (ObviousResidualsWeight).34 The first residual category belongs to estimated values which definitely belong to a specific class because the estimated value is located above the maximum or below the minimum of all the class values (DefiniteResidualsWeight). 35 35 The second residual category represents residuals which belong to the positive class whereby the estimated value is located between the positive and a negative class (PositiveClassResidualsWeight). 36 All other cases are represented by the third category (NegativeClass ResidualsWeight).36 All other cases are represented by the third category (NegativeClassesResidualsWeight). 37 37 The weight is multiplied to the error before squaring which means that the Evaluator acts like a normal MSE-Evaluator if all the weights are set to 1.")] 38 38 [StorableClass] 39 39 public class SymbolicClassificationSingleObjectiveWeightedResidualsMeanSquaredErrorEvaluator : SymbolicClassificationSingleObjectiveEvaluator { 40 private const string ObviousResidualsWeightParameterName = "ObviousResidualsWeight";40 private const string DefiniteResidualsWeightParameterName = "DefiniteResidualsWeight"; 41 41 private const string PositiveClassResidualsWeightParameterName = "PositiveClassResidualsWeight"; 42 private const string NegativeClass ResidualsWeightParameterName = "NegativeClassResidualsWeight";42 private const string NegativeClassesResidualsWeightParameterName = "NegativeClassesResidualsWeight"; 43 43 [StorableConstructor] 44 44 protected SymbolicClassificationSingleObjectiveWeightedResidualsMeanSquaredErrorEvaluator(bool deserializing) : base(deserializing) { } … … 52 52 public SymbolicClassificationSingleObjectiveWeightedResidualsMeanSquaredErrorEvaluator() 53 53 : base() { 54 Parameters.Add(new FixedValueParameter<DoubleValue>( ObviousResidualsWeightParameterName, "Weight of residuals which obviously belong to a specific class because the estimated values is located above the maximum or below the minimum of all the class values.", new DoubleValue(1)));54 Parameters.Add(new FixedValueParameter<DoubleValue>(DefiniteResidualsWeightParameterName, "Weight of residuals which definitely belong to a specific class because the estimated values is located above the maximum or below the minimum of all the class values.", new DoubleValue(1))); 55 55 Parameters.Add(new FixedValueParameter<DoubleValue>(PositiveClassResidualsWeightParameterName, "Weight of residuals which belong to the positive class whereby the estimated value is located between the positive and a negative class.", new DoubleValue(1))); 56 Parameters.Add(new FixedValueParameter<DoubleValue>(NegativeClass ResidualsWeightParameterName, "Weight of residuals which are not covered by the ObviousResidualsWeight or the PositiveClassResidualsWeight.", new DoubleValue(1)));56 Parameters.Add(new FixedValueParameter<DoubleValue>(NegativeClassesResidualsWeightParameterName, "Weight of residuals which are not covered by the DefiniteResidualsWeight or the PositiveClassResidualsWeight.", new DoubleValue(1))); 57 57 } 58 58 59 59 #region parameter properties 60 public IFixedValueParameter<DoubleValue> ObviousResidualsWeightParameter {61 get { return (IFixedValueParameter<DoubleValue>)Parameters[ ObviousResidualsWeightParameterName]; }60 public IFixedValueParameter<DoubleValue> DefiniteResidualsWeightParameter { 61 get { return (IFixedValueParameter<DoubleValue>)Parameters[DefiniteResidualsWeightParameterName]; } 62 62 } 63 63 public IFixedValueParameter<DoubleValue> PositiveClassResidualsWeightParameter { 64 64 get { return (IFixedValueParameter<DoubleValue>)Parameters[PositiveClassResidualsWeightParameterName]; } 65 65 } 66 public IFixedValueParameter<DoubleValue> NegativeClass ResidualsWeightParameter {67 get { return (IFixedValueParameter<DoubleValue>)Parameters[NegativeClass ResidualsWeightParameterName]; }66 public IFixedValueParameter<DoubleValue> NegativeClassesResidualsWeightParameter { 67 get { return (IFixedValueParameter<DoubleValue>)Parameters[NegativeClassesResidualsWeightParameterName]; } 68 68 } 69 69 #endregion … … 72 72 public override bool Maximization { get { return false; } } 73 73 74 public double ObviousResidualsWeight {74 public double DefiniteResidualsWeight { 75 75 get { 76 return ObviousResidualsWeightParameter.Value.Value;76 return DefiniteResidualsWeightParameter.Value.Value; 77 77 } 78 78 } … … 82 82 } 83 83 } 84 public double NegativeClass ResidualsWeight {84 public double NegativeClassesResidualsWeight { 85 85 get { 86 return NegativeClass ResidualsWeightParameter.Value.Value;86 return NegativeClassesResidualsWeightParameter.Value.Value; 87 87 } 88 88 } … … 93 93 var solution = SymbolicExpressionTreeParameter.ActualValue; 94 94 double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value, 95 ObviousResidualsWeight, PositiveClassResidualsWeight, NegativeClassResidualsWeight);95 DefiniteResidualsWeight, PositiveClassResidualsWeight, NegativeClassesResidualsWeight); 96 96 QualityParameter.ActualValue = new DoubleValue(quality); 97 97 return base.InstrumentedApply(); … … 99 99 100 100 public static double Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IClassificationProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, 101 double obviousResidualsWeight, double positiveClassResidualsWeight, double negativeClassResidualsWeight) {101 double definiteResidualsWeight, double positiveClassResidualsWeight, double negativeClassesResidualsWeight) { 102 102 IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 103 103 IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); … … 116 116 if (applyLinearScaling) { 117 117 var calculator = new OnlineWeightedResidualsMeanSquaredErrorCalculator(positiveClassValue, classValuesMax, classValuesMin, 118 obviousResidualsWeight, positiveClassResidualsWeight, negativeClassResidualsWeight);118 definiteResidualsWeight, positiveClassResidualsWeight, negativeClassesResidualsWeight); 119 119 CalculateWithScaling(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, calculator, problemData.Dataset.Rows); 120 120 errorState = calculator.ErrorState; … … 123 123 IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit); 124 124 quality = OnlineWeightedResidualsMeanSquaredErrorCalculator.Calculate(targetValues, boundedEstimatedValues, positiveClassValue, classValuesMax, 125 classValuesMin, obviousResidualsWeight, positiveClassResidualsWeight, negativeClassResidualsWeight, out errorState);125 classValuesMin, definiteResidualsWeight, positiveClassResidualsWeight, negativeClassesResidualsWeight, out errorState); 126 126 } 127 127 if (errorState != OnlineCalculatorError.None) return Double.NaN; … … 134 134 ApplyLinearScalingParameter.ExecutionContext = context; 135 135 136 double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value, ObviousResidualsWeight, PositiveClassResidualsWeight, NegativeClassResidualsWeight);136 double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value, DefiniteResidualsWeight, PositiveClassResidualsWeight, NegativeClassesResidualsWeight); 137 137 138 138 SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
Note: See TracChangeset
for help on using the changeset viewer.