Find Distance to Decision Boundary in Decision Trees
问题 I want to find the distance of samples to the decision boundary of a trained decision trees classifier in scikit-learn. The features are all numeric and the feature space could be of any size. I have this visualization so far for an example 2D case based on here: import numpy as np import matplotlib.pyplot as plt from sklearn.tree import DecisionTreeClassifier from sklearn.datasets import make_moons # Generate some example data X, y = make_moons(noise=0.3, random_state=0) # Train the