holisticai.explainability.metrics.weighted_average_depth#
- holisticai.explainability.metrics.weighted_average_depth(tree)[source]#
Weighted Average Depth calculates the average depth of a tree considering the number of samples that pass through each cut.
Parameters
- tree: Tree
The tree to calculate the weighted average depth of.
Returns
- float
The weighted average depth value
Examples
>>> from sklearn.datasets import load_iris >>> from sklearn.tree import DecisionTreeClassifier >>> from holisticai.explainability.metrics import weighted_average_depth >>> X, y = load_iris(return_X_y=True) >>> clf = DecisionTreeClassifier() >>> clf.fit(X, y) >>> weighted_average_depth(clf.tree_)
Reference#
Laber, E., Murtinho, L., & Oliveira, F. (2023). Shallow decision trees for explainable k-means clustering. Pattern Recognition, 137, 109239.