From 833d787a57f53a4828e3532a9b8d68cb38dfa167 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 21 Nov 2022 16:02:13 +0100 Subject: LMT: implement complexity score --- lib/functions.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/functions.py b/lib/functions.py index c229594..dab317b 100644 --- a/lib/functions.py +++ b/lib/functions.py @@ -605,8 +605,16 @@ class LMTFunction(SKLearnRegressionFunction): def get_number_of_leaves(self): return len(self.regressor._leaves.keys()) - # def get_complexity_score(self): - # FIXME + def get_complexity_score(self): + ret = 0 + print(self.regressor._leaves) + for leaf in self.regressor._leaves.values(): + ret += len( + list( + filter(lambda x: x > 0, leaf.model.coef_ + [leaf.model.intercept_]) + ) + ) + return ret def get_max_depth(self): return max(map(len, self.regressor._leaves.keys())) + 1 -- cgit v1.2.3