skpro.utils.plotting.plot_crossplot_loss#
- skpro.utils.plotting.plot_crossplot_loss(y_true, y_pred, metric, ax=None)[source]#
Cross-loss-plot for probabilistic regression.
Plots:
x-axis: ground truth values \(y_i\)
y-axis: loss of the prediction \(\widehat{y}_i\) corresponding to \(y_i\), as calculated by
metric.evaluate_by_index
- Parameters:
- y_truearray-like, [n_samples, n_targets]
Ground truth values
- y_predskpro distribution, or predict_var return, [n_samples, n_targets]
Predicted values
- metricskpro metric
Metric to calculate the loss
- 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_loss >>> from skpro.metrics import CRPS >>> 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) >>> crps_metric = CRPS() >>> plot_crossplot_loss(y, y_pred, crps_metric)