holisticai.explainability.metrics.tree_depth_variance#
- holisticai.explainability.metrics.tree_depth_variance(tree)[source]#
Compute the variance of the depths of the leaves in the tree (TDV). Reference value: 0.0
Parameters
- treeTree
The tree to compute the depth variance of.
Returns
- float
The variance of the leaf depths.
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) >>> tree_depth_variance(clf.tree_)