Residual charts
daspi.plotlib.precast.ResidualsCharts(linear_model, stretch_figsize=False)
¶
Bases: JointChart
Provides a set of charts for visualizing the residuals of a linear regression model.
The ResidualsCharts class takes a LinearModel instance and
generates a set of four charts:
- Probability plot of the residuals
- Gaussian kernel density estimate of the residuals
- Scatter plot of the predicted values vs. the observed values
- Line plot of the predicted values vs. the observed values
The plot() method generates the charts, and the label() method
adds titles and labels to the charts.
| PARAMETER | DESCRIPTION |
|---|---|
linear_model
|
The linear regression model whose residuals will be visualized.
TYPE:
|
stretch_figsize
|
If True, the height and width of the figure are stretched based on the number rows and columns in the axes grid. If a float is provided, the figure size is stretched by the given factor. If a tuple of two floats is provided, the figure size is stretched by the given factors for the x and y axis, respectively. by default False.
TYPE:
|
Examples:
import daspi as dsp
import pandas as pd
df = dsp.load_dataset('painkillers-dissolution')
model = dsp.LinearModel(
source=df,
target='dissolution',
features=['employee', 'stirrer', 'brand', 'catalyst', 'water'],
covariates=['temperature', 'preparation'],
order=2)
df_gof = pd.concat(model.recursive_elimination())
dsp.ResidualsCharts(model).plot().stripes().label(info=True)

lm = linear_model
instance-attribute
¶
The linear regression model whose residuals are visualized.
plot()
¶
Generates a set of four charts for visualizing the residuals of a linear regression model: - Probability plot of the residuals - Gaussian kernel density estimate of the residuals - Scatter plot of the predicted values vs. the observed values - Line plot of the predicted values vs. the observed values
| RETURNS | DESCRIPTION |
|---|---|
Self
|
The
TYPE:
|
stripes()
¶
Adds a line at position 0 for each subplot except for the probability plot. This line represents the fit of the model.
label(info=False, **kwds)
¶
Adds titles and labels to the charts generated by the
plot() method.
| PARAMETER | DESCRIPTION |
|---|---|
info
|
If
TYPE:
|
**kwds
|
Additional keyword arguments to be passed to the
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
Self
|
The |