The function sklearn.inspection.plot_partial_dependence is not implemented in newer scikit-learn versions.
For example, when trying to execute the partial dependence example from chapter 09_tabular.ipynb in "Model Interpretation -> Partial Dependence" I will get the following error:
from sklearn.inspection import plot_partial_dependence
fig,ax = plt.subplots(figsize=(12, 4))
plot_partial_dependence(m, valid_xs_final, ['YearMade','ProductSize'],
grid_resolution=20, ax=ax);
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[331], line 1
----> 1 from sklearn.inspection import plot_partial_dependence
3 fig,ax = plt.subplots(figsize=(12, 4))
4 plot_partial_dependence(m, valid_xs_final, ['YearMade','ProductSize'],
5 grid_resolution=20, ax=ax);
ImportError: cannot import name 'plot_partial_dependence' from 'sklearn.inspection'
The function
sklearn.inspection.plot_partial_dependence
is not implemented in newer scikit-learn versions. For example, when trying to execute the partial dependence example from chapter 09_tabular.ipynb in "Model Interpretation -> Partial Dependence" I will get the following error:Tested with scikit-learn version:
In the documetation of scikit-learn I can't find
sklearn.inspection.plot_partial_dependence
after version 1.1.In the newer scikit versions (1.2 or 1.3) we can use
sklearn.inspection.PartialDependenceDisplay.from_estimator
insteadFor example:
References: