Wayne Thompson
Wayne Thompson

Reputation: 13

ImportError: cannot import name 'plot_partial_dependence' from 'sklearn.inspection'

I am running sckitlearn 1.3 with the following code and get the following error:

print(__doc__)

import pandas as pd
import matplotlib.pyplot as plt
from sklearn.datasets import load_diabetes
from sklearn.neural_network import MLPRegressor
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import make_pipeline
from sklearn.tree import DecisionTreeRegressor
from sklearn.inspection import plot_partial_dependence

ImportError: cannot import name 'plot_partial_dependence' from 'sklearn.inspection' (C:\Users\thomp\anaconda3\Lib\site-packages\sklearn\inspection_init_.py)

How can I get this package loaded.

This error is returned

ImportError: cannot import name 'plot_partial_dependence' from 'sklearn.inspection' (C:\Users\thomp\anaconda3\Lib\site-packages\sklearn\inspection_init_.py)

Upvotes: 1

Views: 6634

Answers (1)

Fanchen Bao
Fanchen Bao

Reputation: 4289

plot_partial_dependence no longer exists in the inspection module of scikit-learn version 1.3

To use plot_partial_dependence, one has to revert to scikit-learn version 0.24. See the doc.

However, it seems that the current way to plot partial dependence is through PartialDependenceDisplay. One can read the user guide for more information.

Upvotes: 4

Related Questions