StatsModels Visualizers

A basic wrapper for statsmodels that emulates a scikit-learn estimator.

class yellowbrick.contrib.statsmodels.base.StatsModelsWrapper(glm_partial, stated_estimator_type='regressor', scorer=<function r2_score>)[source]

Bases: sklearn.base.BaseEstimator

Wrap a statsmodels GLM as a sklearn (fake) BaseEstimator for YellowBrick.

Notes

Note

This wrapper is trivial, options and extra things like weights are not currently handled.

Examples

First import the external libraries and helper utilities:

>>> import statsmodels.api as sm
>>> from functools import partial

Instantiate a partial with the statsmodels API:

>>> glm_gaussian_partial = partial(sm.GLM, family=sm.families.Gaussian())
>>> sm_est = StatsModelsWrapper(glm_gaussian_partial)

Create a Yellowbrick visualizer to visualize prediction error:

>>> visualizer = PredictionError(sm_est)
>>> visualizer.fit(X_train, y_train)
>>> visualizer.score(X_test, y_test)

For statsmodels usage, calling .summary() etc:

>>> gaussian_model = glm_gaussian_partial(y_train, X_train)
fit(self, X, y)[source]

Pretend to be a sklearn estimator, fit is called on creation

predict(self, X)[source]
score(self, X, y)[source]