summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2022-11-21 16:02:13 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2022-11-21 16:02:13 +0100
commit833d787a57f53a4828e3532a9b8d68cb38dfa167 (patch)
tree30a4878d095d69fafb5813c1a056a4234ad771e4 /lib
parent7c5d107242003f7d68acfe2c3a41e513daa9e78d (diff)
LMT: implement complexity score
Diffstat (limited to 'lib')
-rw-r--r--lib/functions.py12
1 files changed, 10 insertions, 2 deletions
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