PredictionErrorDisplay#
- class skore.PredictionErrorDisplay(*, y_true, y_pred, residuals, range_y_true, range_y_pred, range_residuals, estimator_names, data_source, ml_task, report_type)[source]#
- Visualization of the prediction error of a regression model. - This tool can display “residuals vs predicted” or “actual vs predicted” using scatter plots to qualitatively assess the behavior of a regressor, preferably on held-out data points. - An instance of this class is should created by - EstimatorReport.metrics.prediction_error(). You should not create an instance of this class directly.- Parameters:
- y_truelist of ndarray of shape (n_samples,)
- True values. 
- y_predlist of ndarray of shape (n_samples,)
- Prediction values. 
- residualslist of ndarray of shape (n_samples,)
- Residuals. Equal to - y_true - y_pred.
- range_y_trueRangeData
- Global range of the true values. 
- range_y_predRangeData
- Global range of the predicted values. 
- range_residualsRangeData
- Global range of the residuals. 
- estimator_nameslist of str
- Name of the estimators. 
- data_source{“train”, “test”, “X_y”}
- The data source used to display the prediction error. 
- ml_task{“regression”, “multioutput-regression”}
- The machine learning task. 
- report_type{“cross-validation”, “estimator”, “comparison-estimator”}
- The type of report. 
 
- Attributes:
- line_matplotlib Artist
- Optimal line representing - y_true == y_pred. Therefore, it is a diagonal line for- kind="predictions"and a horizontal line for- kind="residuals".
- errors_lines_matplotlib Artist or None
- Residual lines. If - with_errors=False, then it is set to- None.
- scatter_list of matplotlib Artist
- Scatter data points. 
- ax_matplotlib Axes
- Axes with the different matplotlib axis. 
- figure_matplotlib Figure
- Figure containing the scatter and lines. 
 
 - Examples - >>> from sklearn.datasets import load_diabetes >>> from sklearn.linear_model import Ridge >>> from sklearn.model_selection import train_test_split >>> from skore import EstimatorReport >>> X_train, X_test, y_train, y_test = train_test_split( ... *load_diabetes(return_X_y=True), random_state=0 ... ) >>> classifier = Ridge() >>> report = EstimatorReport( ... classifier, ... X_train=X_train, ... y_train=y_train, ... X_test=X_test, ... y_test=y_test, ... ) >>> display = report.metrics.prediction_error() >>> display.plot(kind="actual_vs_predicted") - plot(ax=None, *, estimator_name=None, kind='residual_vs_predicted', data_points_kwargs=None, perfect_model_kwargs=None, despine=True)[source]#
- Plot visualization. - Extra keyword arguments will be passed to matplotlib’s - plot.- Parameters:
- axmatplotlib axes, default=None
- Axes object to plot on. If - None, a new figure and axes is created.
- estimator_namestr
- Name of the estimator used to plot the prediction error. If - None, we used the inferred name from the estimator.
- kind{“actual_vs_predicted”, “residual_vs_predicted”}, default=”residual_vs_predicted”
- The type of plot to draw: - “actual_vs_predicted” draws the observed values (y-axis) vs. the predicted values (x-axis). 
- “residual_vs_predicted” draws the residuals, i.e. difference between observed and predicted values, (y-axis) vs. the predicted values (x-axis). 
 
- data_points_kwargsdict, default=None
- Dictionary with keywords passed to the - matplotlib.pyplot.scattercall.
- perfect_model_kwargsdict, default=None
- Dictionary with keyword passed to the - matplotlib.pyplot.plotcall to draw the optimal line.
- despinebool, default=True
- Whether to remove the top and right spines from the plot. 
 
 - Examples - >>> from sklearn.datasets import load_diabetes >>> from sklearn.linear_model import Ridge >>> from sklearn.model_selection import train_test_split >>> from skore import EstimatorReport >>> X_train, X_test, y_train, y_test = train_test_split( ... *load_diabetes(return_X_y=True), random_state=0 ... ) >>> classifier = Ridge() >>> report = EstimatorReport( ... classifier, ... X_train=X_train, ... y_train=y_train, ... X_test=X_test, ... y_test=y_test, ... ) >>> display = report.metrics.prediction_error() >>> display.plot(kind="actual_vs_predicted") 
 - set_style(**kwargs)[source]#
- Set the style parameters for the display. - Parameters:
- **kwargsdict
- Style parameters to set. Each parameter name should correspond to a a style attribute passed to the plot method of the display. 
 
- Returns:
- selfobject
- Returns the instance itself. 
 
- Raises:
- ValueError
- If a style parameter is unknown.