Regressor

Inspector functionality specific to regression models
import sklearn.datasets
from sklearn.linear_model import LinearRegression

from model_inspector import get_inspector
X, y = sklearn.datasets.load_diabetes(return_X_y=True, as_frame=True)
inspector = get_inspector(LinearRegression().fit(X, y), X, y)

source

_RegInspector.plot_residuals

 _RegInspector.plot_residuals (axes:Optional[<built-
                               infunctionarray>]=None,
                               scatter_kwargs:Optional[dict]=None,
                               line_kwargs:Optional[dict]=None,
                               hist_kwargs:Optional[dict]=None)

Plot residuals.

Parameters:

  • axes: 1D array of two Matplotlib Axes objects. Plot will be added to these objects if provided; otherwise a new array of Axes objects will be generated.
  • scatter_kwargs: kwargs to pass to plt.scatter
  • line_kwargs: kwargs to pass to plt.plot for line at y=0
  • hist_kwargs: kwargs to pass to plt.hist for histogram of residuals
axes = inspector.plot_residuals()


source

_RegInspector.plot_pred_vs_act

 _RegInspector.plot_pred_vs_act
                                 (ax:Optional[matplotlib.axes._axes.Axes]=
                                 None, scatter_kwargs:Optional[dict]=None,
                                 line_kwargs:Optional[dict]=None)

Plot predicted vs. actual values.

Parameters:

  • ax: Matplotlib Axes object. Plot will be added to this object if provided; otherwise a new Axes object will be generated.
  • scatter_kwargs: kwargs to pass to plt.scatter
  • line_kwargs: kwargs to pass to plt.plot
ax = inspector.plot_pred_vs_act()