linreg_ally.plotting
Functions
|
Generate a Q-Q plot (standardized residuals vs theoretical quantiles) |
Module Contents
- linreg_ally.plotting.qq_and_residuals_plot(y_actual, y_predicted, concatenate=True)[source]
Generate a Q-Q plot (standardized residuals vs theoretical quantiles) and a Residuals vs. Fitted Values plot using Altair for regression diagnostics.
- Parameters:
y_actual (array-like) – Actual observed values from the dataset. Must be numeric and have the same length as y_predicted.
y_predicted (array-like) – Predicted (fitted) values from the regression model. Must be numeric and have the same length as y_actual.
concatenate (bool, optional (default=True)) – If True, concatenates the Q-Q plot and Residuals vs. Fitted Values plot side by side. If False, returns the plots separately as individual Altair charts.
- Returns:
If concatenate=True, returns a concatenated Altair chart with both plots.
If concatenate=False, returns a tuple containing the Q-Q plot and Residuals vs. Fitted Values plot.
- Return type:
alt.Chart or tuple of alt.Chart
- Raises:
ValueError – If y_actual or y_predicted are empty, have mismatched lengths, or contain fewer than two data points.
TypeError – If y_actual or y_predicted are not numeric.
Examples
>>> import numpy as np >>> np.random.seed(42) >>> y_actual = np.random.normal(10, 2, 100) >>> y_predicted = y_actual + np.random.normal(0, 1, 100) >>> chart = qq_and_residuals_plot(y_actual, y_predicted, concatenate=True) >>> chart.display()