Open
Description
Describe the workflow you want to enable
Currently, partial dependence plots (PDP) and ICE profiles can be conveniently visualized by calling PartialDependenceDisplay.from_estimator
. This works as long as the model is a valid scikit-learn estimator.
Since PDP/ICE actually only require the availability of a prediction function, I'd love to be able to pass only a prediction function taking an array-like input X and providing numeric output values.
Describe your proposed solution
Add method PartialDependenceDisplay.from_predict_fun
that would enable above solution.
Trivial (but not working) example:
import numpy as np
from sklearn.inspection import PartialDependenceDisplay
X = np.array([range(10)]).reshape(5, -1)
def predict_fun(X):
return np.repeat(3, X.shape[0])
PartialDependenceDisplay.from_predict_fun(
predict_fun,
X
)
Describe alternatives you've considered, if relevant
Define custom estimator.
Additional context
No response