Plots residuals (errors) of a regression model. Args: y_true (array-like): True values. y_pred (array-like): Predicted values.
(y_true, y_pred)
| 85 | |
| 86 | |
| 87 | def plot_residuals(y_true, y_pred): |
| 88 | """ |
| 89 | Plots residuals (errors) of a regression model. |
| 90 | |
| 91 | Args: |
| 92 | y_true (array-like): True values. |
| 93 | y_pred (array-like): Predicted values. |
| 94 | """ |
| 95 | residuals = y_true - y_pred |
| 96 | |
| 97 | plt.figure(figsize=(10, 6)) |
| 98 | plt.scatter(y_pred, residuals, color="purple", alpha=0.5) |
| 99 | plt.axhline(y=0, color="black", linestyle="--") |
| 100 | plt.xlabel("Predicted Values") |
| 101 | plt.ylabel("Residuals") |
| 102 | plt.title("Residual Plot") |
| 103 | plt.grid(alpha=0.5) |
| 104 | plt.show() |
| 105 | |
| 106 | |
| 107 | def plot_actual_vs_predicted(y_true, y_pred): |
nothing calls this directly
no outgoing calls
no test coverage detected