'Issue with the prediction error plot using the yellowbrick library (regression)

I have three models for regression:

  • linear regression: using ols_regressor = sm.OLS()
  • random forest: using rf = RandomForestRegressor()
  • artificial neural network: using tensorflow and keras

I would like to plot a prediction error plot for the three models and I came across the yellowbrick library that seemed pretty straightforward.

In their documentation they have two ways of applying their functions:

# Method 1:
from yellowbrick.regressor import PredictionError

# Instantiate the linear model and visualizer
model = Lasso()
visualizer = PredictionError(model)

visualizer.fit(X_train, y_train)  # Fit the training data to the visualizer
visualizer.score(X_test, y_test)  # Evaluate the model on the test data
visualizer.show()                 # Finalize and render the figure

# Method 2:
from yellowbrick.regressor import prediction_error

# Instantiate the linear model and visualizer
model = Lasso()
visualizer = prediction_error(model, X_train, y_train, X_test, y_test)

When trying either, I get the following error for the linear regression and NN models:

YellowbrickTypeError: This estimator is not a regressor; try a classifier or clustering score visualizer instead!

It plots fine for the Random Forest.

They are regressors, and I don't have any categorical variable in my data. Why is this happening? What alternative I could use or what should I add?

Source: https://www.scikit-yb.org/en/latest/api/regressor/peplot.html



Solution 1:[1]

Yellowbrick is specifically built for scikit-learn style estimators but we have introduced some tools that will allow for NN.

https://www.scikit-yb.org/en/latest/api/contrib/wrapper.html

https://www.scikit-yb.org/en/latest/api/contrib/prepredict.html#module-yellowbrick.contrib.prepredict

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 larrywgray