NameError: name 'cross_validate' is not defined

getting the below error when running the code

from sklearn.dummy import DummyRegressor

dummy = DummyRegressor(strategy="mean")
result_dummy = cross_validate(
    dummy, data, target, cv=cv,
    scoring="neg_mean_absolute_error", n_jobs=2
)
errors_dummy_regressor = pd.Series(
    -result_dummy["test_score"], name="Dummy regressor"
)
errors_dummy_regressor.describe()

NameError: name ‘cross_validate’ is not defined

could you please let me know your thoughts?

The error says that you have not defined (imported) the function cross_validate. This was possibly done in a previous cell of code that you are not running.
To solve the issue, run:

from sklearn.model_selection import cross_validate

before the cell of code you provided.

1 Like