skpro.utils.plotting.plot_crossplot_interval#
- skpro.utils.plotting.plot_crossplot_interval(y_true, y_pred, coverage=None, ax=None)[source]#
Probabilistic cross-plot for regression, truth vs prediction interval.
Plots:
x-axis: ground truth value
y-axis: median predictive value, with error bars being the prediction interval at symmetric coverage
coverage
- Parameters:
- y_truearray-like, [n_samples, n_targets]
Ground truth values
- y_predskpro distribution, or predict_interval return, [n_samples, n_targets]
symmetric prediction intervals are obtained via the coverage parameterfrom y_pred Predicted values
- coveragefloat, optional, default=0.9
Coverage of the prediction interval Used only if y_pred a distribution
- axmatplotlib axes, optional
Axes to plot on, if None, a new figure is created and returned
- Returns:
- axmatplotlib axes
Axes containing the plot If ax was None, a new figure is created and returned If ax was not None, the same ax is returned with plot added
Examples
>>> from skpro.utils.plotting import plot_crossplot_interval >>> from skpro.regression.residual import ResidualDouble >>> from sklearn.ensemble import RandomForestRegressor >>> from sklearn.linear_model import LinearRegression >>> from sklearn.datasets import load_diabetes >>> >>> X, y = load_diabetes(return_X_y=True, as_frame=True) >>> reg_mean = LinearRegression() >>> reg_resid = RandomForestRegressor() >>> reg_proba = ResidualDouble(reg_mean, reg_resid) >>> >>> reg_proba.fit(X, y) ResidualDouble(...) >>> y_pred = reg_proba.predict_proba(X) >>> plot_crossplot_interval(y, y_pred)