PredictionErrorDisplay
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.
See the details in the docstrings of from\_estimator
or from\_predictions
to create a visualizer. All parameters are stored as attributes.
For general information regarding scikit-learn
visualization tools, read more in the Visualization Guide. For details regarding interpreting these plots, refer to the Model Evaluation Guide.
Python Reference (opens in a new tab)
Constructors
constructor()
Signature
new PredictionErrorDisplay(opts?: object): PredictionErrorDisplay;
Parameters
Name | Type | Description |
---|---|---|
opts? | object | - |
opts.y_pred? | ArrayLike | Prediction values. |
opts.y_true? | ArrayLike | True values. |
Returns
Defined in: generated/metrics/PredictionErrorDisplay.ts:27 (opens in a new tab)
Methods
dispose()
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
Signature
dispose(): Promise<void>;
Returns
Promise
<void
>
Defined in: generated/metrics/PredictionErrorDisplay.ts:101 (opens in a new tab)
from_estimator()
Plot the prediction error given a regressor and some data.
For general information regarding scikit-learn
visualization tools, read more in the Visualization Guide. For details regarding interpreting these plots, refer to the Model Evaluation Guide.
Signature
from_estimator(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | Input values. |
opts.ax? | any | Axes object to plot on. If undefined , a new figure and axes is created. |
opts.estimator? | any | Fitted regressor or a fitted Pipeline in which the last estimator is a regressor. |
opts.kind? | "actual_vs_predicted" | "residual_vs_predicted" | The type of plot to draw: Default Value 'residual_vs_predicted' |
opts.line_kwargs? | any | Dictionary with keyword passed to the matplotlib.pyplot.plot call to draw the optimal line. |
opts.random_state? | number | Controls the randomness when subsample is not undefined . See Glossary for details. |
opts.scatter_kwargs? | any | Dictionary with keywords passed to the matplotlib.pyplot.scatter call. |
opts.subsample? | number | Sampling the samples to be shown on the scatter plot. If float , it should be between 0 and 1 and represents the proportion of the original dataset. If int , it represents the number of samples display on the scatter plot. If undefined , no subsampling will be applied. by default, a 1000 samples or less will be displayed. Default Value 1 |
opts.y? | ArrayLike | Target values. |
Returns
Promise
<any
>
Defined in: generated/metrics/PredictionErrorDisplay.ts:120 (opens in a new tab)
from_predictions()
Plot the prediction error given the true and predicted targets.
For general information regarding scikit-learn
visualization tools, read more in the Visualization Guide. For details regarding interpreting these plots, refer to the Model Evaluation Guide.
Signature
from_predictions(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.ax? | any | Axes object to plot on. If undefined , a new figure and axes is created. |
opts.kind? | "actual_vs_predicted" | "residual_vs_predicted" | The type of plot to draw: Default Value 'residual_vs_predicted' |
opts.line_kwargs? | any | Dictionary with keyword passed to the matplotlib.pyplot.plot call to draw the optimal line. |
opts.random_state? | number | Controls the randomness when subsample is not undefined . See Glossary for details. |
opts.scatter_kwargs? | any | Dictionary with keywords passed to the matplotlib.pyplot.scatter call. |
opts.subsample? | number | Sampling the samples to be shown on the scatter plot. If float , it should be between 0 and 1 and represents the proportion of the original dataset. If int , it represents the number of samples display on the scatter plot. If undefined , no subsampling will be applied. by default, a 1000 samples or less will be displayed. Default Value 1 |
opts.y_pred? | ArrayLike | Predicted target values. |
opts.y_true? | ArrayLike | True target values. |
Returns
Promise
<any
>
Defined in: generated/metrics/PredictionErrorDisplay.ts:214 (opens in a new tab)
init()
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Signature
init(py: PythonBridge): Promise<void>;
Parameters
Name | Type |
---|---|
py | PythonBridge |
Returns
Promise
<void
>
Defined in: generated/metrics/PredictionErrorDisplay.ts:55 (opens in a new tab)
plot()
Plot visualization.
Extra keyword arguments will be passed to matplotlib’s plot
.
Signature
plot(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.ax? | any | Axes object to plot on. If undefined , a new figure and axes is created. |
opts.kind? | "actual_vs_predicted" | "residual_vs_predicted" | The type of plot to draw: Default Value 'residual_vs_predicted' |
opts.line_kwargs? | any | Dictionary with keyword passed to the matplotlib.pyplot.plot call to draw the optimal line. |
opts.scatter_kwargs? | any | Dictionary with keywords passed to the matplotlib.pyplot.scatter call. |
Returns
Promise
<any
>
Defined in: generated/metrics/PredictionErrorDisplay.ts:301 (opens in a new tab)
Properties
_isDisposed
boolean
=false
Defined in: generated/metrics/PredictionErrorDisplay.ts:25 (opens in a new tab)
_isInitialized
boolean
=false
Defined in: generated/metrics/PredictionErrorDisplay.ts:24 (opens in a new tab)
_py
PythonBridge
Defined in: generated/metrics/PredictionErrorDisplay.ts:23 (opens in a new tab)
id
string
Defined in: generated/metrics/PredictionErrorDisplay.ts:20 (opens in a new tab)
opts
any
Defined in: generated/metrics/PredictionErrorDisplay.ts:21 (opens in a new tab)
Accessors
ax_
Axes with the different matplotlib axis.
Signature
ax_(): Promise<any>;
Returns
Promise
<any
>
Defined in: generated/metrics/PredictionErrorDisplay.ts:436 (opens in a new tab)
errors_lines_
Residual lines. If with\_errors=False
, then it is set to undefined
.
Signature
errors_lines_(): Promise<any>;
Returns
Promise
<any
>
Defined in: generated/metrics/PredictionErrorDisplay.ts:382 (opens in a new tab)
figure_
Figure containing the scatter and lines.
Signature
figure_(): Promise<any>;
Returns
Promise
<any
>
Defined in: generated/metrics/PredictionErrorDisplay.ts:463 (opens in a new tab)
line_
Optimal line representing y\_true \== y\_pred
. Therefore, it is a diagonal line for kind="predictions"
and a horizontal line for kind="residuals"
.
Signature
line_(): Promise<any>;
Returns
Promise
<any
>
Defined in: generated/metrics/PredictionErrorDisplay.ts:355 (opens in a new tab)
py
Signature
py(): PythonBridge;
Returns
PythonBridge
Defined in: generated/metrics/PredictionErrorDisplay.ts:42 (opens in a new tab)
Signature
py(pythonBridge: PythonBridge): void;
Parameters
Name | Type |
---|---|
pythonBridge | PythonBridge |
Returns
void
Defined in: generated/metrics/PredictionErrorDisplay.ts:46 (opens in a new tab)
scatter_
Scatter data points.
Signature
scatter_(): Promise<any>;
Returns
Promise
<any
>
Defined in: generated/metrics/PredictionErrorDisplay.ts:409 (opens in a new tab)