Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/11/13 13:32:32 (12 years ago)
Author:
sforsten
Message:

#1980:

  • set plugin dependencies
  • added smart initialization
  • added hierarchical selection
  • fixed major and minor default rule
  • fixed several smaller bugs
  • some refactoring has been done
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/LearningClassifierSystems/HeuristicLab.Encodings.DecisionList/3.3/Evaluator/MDLEvaluator.cs

    r9475 r9605  
    4949      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
    5050    }
     51    public ILookupParameter<DoubleValue> LengthParameter {
     52      get { return (ILookupParameter<DoubleValue>)Parameters["Length"]; }
     53    }
    5154    public IValueLookupParameter<IDecisionListClassificationProblemData> ProblemDataParameter {
    5255      get { return (IValueLookupParameter<IDecisionListClassificationProblemData>)Parameters["ProblemData"]; }
    5356    }
    5457
     58    public IValueLookupParameter<BoolValue> UseMDLParameter {
     59      get { return (IValueLookupParameter<BoolValue>)Parameters["UseMDL"]; }
     60    }
    5561    public ILookupParameter<MDLCalculator> MDLCalculatorParameter {
    5662      get { return (ILookupParameter<MDLCalculator>)Parameters["MDLCalculator"]; }
     
    7379      get { return (ILookupParameter<ItemList<ItemList<IntValue>>>)Parameters["Strata"]; }
    7480    }
     81    public IValueLookupParameter<BoolValue> MaximizationParameter {
     82      get { return (IValueLookupParameter<BoolValue>)Parameters["Maximization"]; }
     83    }
    7584    #endregion
    7685
     
    9099      Parameters.Add(new ValueLookupParameter<IntValue>("SizePenaltyMinRules", ""));
    91100      Parameters.Add(new LookupParameter<DoubleValue>("Quality", ""));
     101      Parameters.Add(new LookupParameter<DoubleValue>("Length", ""));
    92102      Parameters.Add(new ValueLookupParameter<IDecisionListClassificationProblemData>("ProblemData", ""));
     103      Parameters.Add(new ValueLookupParameter<BoolValue>("UseMDL", "", new BoolValue(true)));
    93104      Parameters.Add(new LookupParameter<MDLCalculator>("MDLCalculator", ""));
    94105      Parameters.Add(new LookupParameter<IntValue>("Iterations", ""));
     
    97108      Parameters.Add(new ValueLookupParameter<IntValue>("RuleDeletionMinRules", "", new IntValue(12)));
    98109      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;
    99117    }
    100118    public override IDeepCloneable Clone(Cloner cloner) {
     
    103121
    104122    public override IOperation Apply() {
    105       double penalty = 1;
    106 
    107123      var strata = StrataParameter.ActualValue;
    108124      int iteration = IterationsParameter.ActualValue.Value;
     
    125141      var estimated = dl.Evaluate(input, out aliveRules, out theoryLength);
    126142
     143      double penalty = 1;
    127144      if (aliveRules.Count < SizePenaltyMinRulesParameter.ActualValue.Value) {
    128145        penalty = (1 - 0.025 * (SizePenaltyMinRulesParameter.ActualValue.Value - aliveRules.Count));
     
    132149
    133150      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      }
    135157
    136158      if (iteration >= IterationRuleDeletionParameter.ActualValue.Value) {
     
    141163        }
    142164      }
     165
     166      LengthParameter.ActualValue = new DoubleValue(dl.Length * aliveRules.Count / dl.RuleSetSize);
    143167      return base.Apply();
    144168    }
Note: See TracChangeset for help on using the changeset viewer.