Plotting¶
rgram.plot_diagnostics¶
rgram.plot_diagnostics(
estimator,
X,
y,
)Plot residuals and observed-versus-predicted values without sorting rows.
Parameters¶
estimatorRegressogram or KernelSmootherSuccessfully fitted model providing regression_diagnostics. For a pipeline, use the final estimator with transformed feature coordinates.
Xarray-like of shape (n_samples,) or (n_samples, 1)Evaluation feature values, aligned with y.
yarray-like of shape (n_samples,) or (n_samples, 1)Observed responses, for training or held-out observations.
Returns¶
figurematplotlib.figure.FigureFigure containing both diagnostic panels and a support-count title.
axesndarray of shape (2,)Residual-versus-feature axis and observed-versus-predicted axis.
Raises¶
ImportErrorIf Matplotlib is absent; install rgram[plot].
sklearn.exceptions.NotFittedErrorIf the estimator has no successful fit.
ValueErrorIf evaluation pairs are invalid or strict prediction policies raise.
Notes¶
Uses scatter points, never connecting or sorting observation rows. Unsupported rows remain in the diagnostic table and are counted in the title, though non-finite points cannot be drawn. No data is modified. The caller chooses whether to display, save, or close the returned figure.
Examples¶
>>> from rgram import Regressogram, plot_diagnostics
>>> model = Regressogram(n_bins=2).fit([0., 1., 2.], [1., 3., 4.])
>>> figure, axes = plot_diagnostics(model, [0., 1., 2.], [1., 3., 4.])
>>> len(axes)
2
The helper expects a Rgram estimator and feature values in that estimator's
coordinate system. For a pipeline, transform the features through
pipeline[:-1] and pass its final estimator. It returns a Matplotlib figure and
a two-element array of axes; calling plt.show() or saving the figure is up to
the caller. See the worked examples.
Implementation source: plotting.py.