Changeset 9605 for branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Evaluator
- Timestamp:
- 06/11/13 13:32:32 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Evaluator/MDLEvaluator.cs
r9475 r9605 49 49 get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; } 50 50 } 51 public ILookupParameter<DoubleValue> LengthParameter { 52 get { return (ILookupParameter<DoubleValue>)Parameters["Length"]; } 53 } 51 54 public IValueLookupParameter<IDecisionListClassificationProblemData> ProblemDataParameter { 52 55 get { return (IValueLookupParameter<IDecisionListClassificationProblemData>)Parameters["ProblemData"]; } 53 56 } 54 57 58 public IValueLookupParameter<BoolValue> UseMDLParameter { 59 get { return (IValueLookupParameter<BoolValue>)Parameters["UseMDL"]; } 60 } 55 61 public ILookupParameter<MDLCalculator> MDLCalculatorParameter { 56 62 get { return (ILookupParameter<MDLCalculator>)Parameters["MDLCalculator"]; } … … 73 79 get { return (ILookupParameter<ItemList<ItemList<IntValue>>>)Parameters["Strata"]; } 74 80 } 81 public IValueLookupParameter<BoolValue> MaximizationParameter { 82 get { return (IValueLookupParameter<BoolValue>)Parameters["Maximization"]; } 83 } 75 84 #endregion 76 85 … … 90 99 Parameters.Add(new ValueLookupParameter<IntValue>("SizePenaltyMinRules", "")); 91 100 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "")); 101 Parameters.Add(new LookupParameter<DoubleValue>("Length", "")); 92 102 Parameters.Add(new ValueLookupParameter<IDecisionListClassificationProblemData>("ProblemData", "")); 103 Parameters.Add(new ValueLookupParameter<BoolValue>("UseMDL", "", new BoolValue(true))); 93 104 Parameters.Add(new LookupParameter<MDLCalculator>("MDLCalculator", "")); 94 105 Parameters.Add(new LookupParameter<IntValue>("Iterations", "")); … … 97 108 Parameters.Add(new ValueLookupParameter<IntValue>("RuleDeletionMinRules", "", new IntValue(12))); 98 109 Parameters.Add(new ValueLookupParameter<ItemList<ItemList<IntValue>>>("Strata", "")); 110 Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "", new BoolValue(false))); 111 112 UseMDLParameter.Value.ValueChanged += UseMDLParameter_ValueChanged; 113 } 114 115 private void UseMDLParameter_ValueChanged(object sender, System.EventArgs e) { 116 MaximizationParameter.Value.Value = !UseMDLParameter.Value.Value; 99 117 } 100 118 public override IDeepCloneable Clone(Cloner cloner) { … … 103 121 104 122 public override IOperation Apply() { 105 double penalty = 1;106 107 123 var strata = StrataParameter.ActualValue; 108 124 int iteration = IterationsParameter.ActualValue.Value; … … 125 141 var estimated = dl.Evaluate(input, out aliveRules, out theoryLength); 126 142 143 double penalty = 1; 127 144 if (aliveRules.Count < SizePenaltyMinRulesParameter.ActualValue.Value) { 128 145 penalty = (1 - 0.025 * (SizePenaltyMinRulesParameter.ActualValue.Value - aliveRules.Count)); … … 132 149 133 150 double accuracy = DecisionListSolution.CalculateAccuracy(actions, estimated); 134 QualityParameter.ActualValue = new DoubleValue(MDLCalculatorParameter.ActualValue.CalculateFitness(theoryLength, accuracy) / penalty); 151 if (UseMDLParameter.ActualValue.Value) { 152 QualityParameter.ActualValue = 153 new DoubleValue(MDLCalculatorParameter.ActualValue.CalculateFitness(theoryLength, accuracy) / penalty); 154 } else { 155 QualityParameter.ActualValue = new DoubleValue(accuracy * accuracy * penalty); 156 } 135 157 136 158 if (iteration >= IterationRuleDeletionParameter.ActualValue.Value) { … … 141 163 } 142 164 } 165 166 LengthParameter.ActualValue = new DoubleValue(dl.Length * aliveRules.Count / dl.RuleSetSize); 143 167 return base.Apply(); 144 168 }
Note: See TracChangeset
for help on using the changeset viewer.