- Timestamp:
- 08/20/10 12:45:57 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/Operators/CovariantParsimonyPressure.cs
r4255 r4271 60 60 get { return (IValueLookupParameter<IntValue>)Parameters["FirstGenerationParameter"]; } 61 61 } 62 public IValueLookupParameter<BoolValue> A ntiOverfitParameter {63 get { return (IValueLookupParameter<BoolValue>)Parameters["A ntiOverfit"]; }62 public IValueLookupParameter<BoolValue> ApplyParsimonyPressureParameter { 63 get { return (IValueLookupParameter<BoolValue>)Parameters["ApplyParsimonyPressure"]; } 64 64 } 65 65 public ILookupParameter<DataTable> ValidationQualityParameter { 66 66 get { return (ILookupParameter<DataTable>)Parameters["Validation Quality"]; } 67 67 } 68 public ILookupParameter<DoubleValue> CurrentBestValidationQualityParameter {69 get { return (ILookupParameter<DoubleValue>)Parameters["Current best validation quality"]; }70 }71 public ILookupParameter<DoubleValue> BestValidationQualityParameter {72 get { return (ILookupParameter<DoubleValue>)Parameters["Best solution quality (validation)"]; }73 }68 //public ILookupParameter<DoubleValue> CurrentBestValidationQualityParameter { 69 // get { return (ILookupParameter<DoubleValue>)Parameters["Current best validation quality"]; } 70 //} 71 //public ILookupParameter<DoubleValue> BestValidationQualityParameter { 72 // get { return (ILookupParameter<DoubleValue>)Parameters["Best solution quality (validation)"]; } 73 //} 74 74 public ILookupParameter<DoubleValue> LengthCorrelationParameter { 75 75 get { return (ILookupParameter<DoubleValue>)Parameters["Correlation(Length, AdjustedFitness)"]; } … … 78 78 get { return (ILookupParameter<DoubleValue>)Parameters["Correlation(Fitness, AdjustedFitness)"]; } 79 79 } 80 public IValueLookupParameter<IntValue> GenerationSpanParameter {81 get { return (IValueLookupParameter<IntValue>)Parameters["GenerationSpan"]; }82 }83 public IValueLookupParameter<PercentValue> OverfittingLimitParameter {84 get { return (IValueLookupParameter<PercentValue>)Parameters["OverfittingLimit"]; }85 }80 //public IValueLookupParameter<IntValue> GenerationSpanParameter { 81 // get { return (IValueLookupParameter<IntValue>)Parameters["GenerationSpan"]; } 82 //} 83 //public IValueLookupParameter<PercentValue> OverfittingLimitParameter { 84 // get { return (IValueLookupParameter<PercentValue>)Parameters["OverfittingLimit"]; } 85 //} 86 86 public IValueLookupParameter<PercentValue> ComplexityAdaptionParameter { 87 87 get { return (IValueLookupParameter<PercentValue>)Parameters["ComplexityAdaption"]; } … … 101 101 Parameters.Add(new LookupParameter<IntValue>("Generations")); 102 102 Parameters.Add(new ValueLookupParameter<IntValue>("FirstGenerationParameter", new IntValue(5))); 103 Parameters.Add(new ValueLookupParameter<BoolValue>("A ntiOverfit", new BoolValue(false)));103 Parameters.Add(new ValueLookupParameter<BoolValue>("ApplyParsimonyPressure")); 104 104 //Parameters.Add(new LookupParameter<DoubleValue>("Current best validation quality")); 105 105 //Parameters.Add(new LookupParameter<DoubleValue>("Best solution quality (validation)")); 106 106 Parameters.Add(new LookupParameter<DataTable>("Validation Quality")); 107 107 Parameters.Add(new LookupParameter<DataTable>("Qualities")); 108 Parameters.Add(new ValueLookupParameter<IntValue>("GenerationSpan", new IntValue(5)));109 Parameters.Add(new ValueLookupParameter<PercentValue>("OverfittingLimit", new PercentValue(5)));108 //Parameters.Add(new ValueLookupParameter<IntValue>("GenerationSpan", new IntValue(5))); 109 //Parameters.Add(new ValueLookupParameter<PercentValue>("OverfittingLimit", new PercentValue(5))); 110 110 Parameters.Add(new ValueLookupParameter<PercentValue>("ComplexityAdaption", new PercentValue(-5))); 111 111 Parameters.Add(new LookupParameter<DoubleValue>("Correlation(Length, AdjustedFitness)")); … … 128 128 Parameters.Add(new ValueLookupParameter<IntValue>("FirstGenerationParameter", new IntValue(5))); 129 129 } 130 if (!Parameters.ContainsKey("A ntiOverfit")) {131 Parameters.Add(new ValueLookupParameter<BoolValue>("A ntiOverfit", new BoolValue(false)));130 if (!Parameters.ContainsKey("ApplyParsimonyPressure")) { 131 Parameters.Add(new ValueLookupParameter<BoolValue>("ApplyParsimonyPressure")); 132 132 } 133 133 //if (!Parameters.ContainsKey("Current best validation quality")) { … … 149 149 Parameters.Add(new LookupParameter<DataTable>("Qualities")); 150 150 } 151 if (!Parameters.ContainsKey("GenerationSpan")) {152 Parameters.Add(new ValueLookupParameter<IntValue>("GenerationSpan", new IntValue(5)));153 }154 if (!Parameters.ContainsKey("OverfittingLimit")) {155 Parameters.Add(new ValueLookupParameter<PercentValue>("OverfittingLimit", new PercentValue(5)));156 }157 151 if (!Parameters.ContainsKey("ComplexityAdaption")) { 158 152 Parameters.Add(new ValueLookupParameter<PercentValue>("ComplexityAdaption", new PercentValue(-5))); … … 163 157 ItemArray<SymbolicExpressionTree> trees = SymbolicExpressionTreeParameter.ActualValue; 164 158 ItemArray<DoubleValue> qualities = QualityParameter.ActualValue; 165 // always apply Parsimony pressure if anti-overfit is false159 // always apply Parsimony pressure if overfitting has been detected 166 160 // otherwise appliy PP only when we are currently overfitting 167 161 if (GenerationsParameter.ActualValue != null && GenerationsParameter.ActualValue.Value >= FirstGenerationParameter.ActualValue.Value && 168 (AntiOverfitParameter.ActualValue.Value == false || IsOverfitting())) {162 ApplyParsimonyPressureParameter.ActualValue.Value == true) { 169 163 var lengths = from tree in trees 170 164 select tree.Size; … … 241 235 return base.Apply(); 242 236 } 243 244 private bool IsOverfitting() {245 bool maximization = MaximizationParameter.ActualValue.Value;246 DataTable trainingQualities = QualitiesParameter.ActualValue;247 DataTable validationQualities = ValidationQualityParameter.ActualValue;248 int genSpan = GenerationSpanParameter.ActualValue.Value;249 if (validationQualities == null || trainingQualities == null) return false;250 if (validationQualities.Rows["Best solution quality (validation)"].Values.Count < genSpan) return false;251 252 IEnumerable<double> bestTrainingQualities = trainingQualities.Rows["CurrentBestQuality"].Values;253 IEnumerable<double> bestValidationQualities = validationQualities.Rows["Current best validation quality"].Values;254 255 double trainingAvg = bestTrainingQualities.Reverse().Take(genSpan).Average();256 double validationAvg = bestValidationQualities.Reverse().Take(genSpan).Average();257 258 double maxPercentDiff = OverfittingLimitParameter.ActualValue.Value;259 260 double percentDiff = maximization ? trainingAvg / validationAvg - 1 : validationAvg / trainingAvg - 1;261 return percentDiff > maxPercentDiff;262 }263 237 } 264 238 }
Note: See TracChangeset
for help on using the changeset viewer.