Fix nodes_leaves for base_estimator

This commit is contained in:
Ricardo Montañana Gómez 2021-11-24 10:50:19 +01:00
parent 3558c946a8
commit 74343a15e1
Signed by: rmontanana
GPG Key ID: 46064262FD9A7ADE

View File

@ -88,13 +88,14 @@ class Odte(BaseEnsemble, ClassifierMixin):
return self
def _compute_metrics(self) -> None:
tdepth = tnodes = tleaves = 0
tdepth = tnodes = tleaves = 0.0
for estimator in self.estimators_:
nodes, leaves = estimator.nodes_leaves()
depth = estimator.depth_
tdepth += depth
tnodes += nodes
tleaves += leaves
if hasattr(estimator, "nodes_leaves"):
nodes, leaves = estimator.nodes_leaves()
depth = estimator.depth_
tdepth += depth
tnodes += nodes
tleaves += leaves
self.depth_ = tdepth / self.n_estimators
self.leaves_ = tleaves / self.n_estimators
self.nodes_ = tnodes / self.n_estimators