treeple.tree.compute_forest_similarity_matrix#

treeple.tree.compute_forest_similarity_matrix(forest, X)[source]#

Compute the similarity matrix of samples in X using a trained forest.

As an intermediate calculation, the forest applies the dataset and gets the leaves for each sample. Then, the similarity matrix is computed by counting the number of times each pair of samples ends up in the same leaf.

Parameters:
forestBaseForest or BaseDecisionTree

The fitted forest.

Xarray_like of shape (n_samples, n_features)

The input data.

Returns:
aff_matrixarray_like of shape (n_samples, n_samples)

The estimated distance matrix.