plot_residuals¶
yohou.plotting.evaluation.plot_residuals(y_pred, y_truth, *, columns=None, groups=None, facet_by='member', facet_n_cols=2, color_palette=None, show_legend=True, title=None, x_label=None, y_label=None, width=None, height=None, resampler=None, marker_size=4, marker_opacity=0.6, n_bins=30)
¶
Plot diagnostic plots for model residuals.
When a single column is selected, creates a 4-panel layout with residuals over time, residuals vs fitted values, histogram of residuals, and Q-Q plot for checking normality assumptions. When multiple columns are resolved (through columns or groups), produces a faceted layout showing residuals over time for each column.
Residuals are computed internally as y_truth - y_pred for matching
non-time columns.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
y_pred
|
DataFrame
|
Predicted values with |
required |
y_truth
|
DataFrame
|
Ground-truth values with |
required |
columns
|
str | list[str] | None
|
Column(s) to compute residuals for. When groups is
set, acts as a member postfix filter (e.g. |
None
|
groups
|
list[str] | None
|
Panel group prefixes to facet by. |
None
|
facet_by
|
Literal['group', 'member'] | None
|
Faceting axis for panel data. |
"member"
|
facet_n_cols
|
int
|
Number of columns in the faceted grid when multiple target columns are resolved. |
2
|
color_palette
|
list[str] | None
|
Custom color palette. If None, uses yohou palette. |
None
|
show_legend
|
bool
|
Whether to show the legend. |
True
|
title
|
str | None
|
Plot title. |
None
|
x_label
|
str | None
|
X-axis label. |
None
|
y_label
|
str | None
|
Y-axis label. |
None
|
width
|
int | None
|
Plot width in pixels. |
None
|
height
|
int | None
|
Plot height in pixels. |
None
|
resampler
|
bool | Literal['widget'] | None
|
Enable plotly-resampler for large datasets. |
None
|
marker_size
|
float
|
Marker size for scatter plots. |
4
|
marker_opacity
|
float
|
Marker opacity. |
0.6
|
n_bins
|
int
|
Number of bins for histogram (single-column diagnostics). |
30
|
Returns¶
| Type | Description |
|---|---|
Figure
|
Plotly figure object. |
Examples¶
>>> dates = pl.date_range(pl.date(2020, 1, 1), pl.date(2020, 3, 31), "1d", eager=True)
>>> y_truth = pl.DataFrame({"time": dates, "y": [100 + i for i in range(91)]})
>>> y_pred = pl.DataFrame({"time": dates, "y": [100 + i + (i % 3) for i in range(91)]})
See Also¶
plot_forecast : Plot forecasts with historical data.
Source Code¶
Show/Hide source
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | |
Tutorials¶
The following example notebooks use this component:
-
Forecasting Workflow
Getting-Started
Evaluate forecasters with cross-validation, search hyperparameters with GridSearchCV, and inspect residuals to diagnose model weaknesses.
-
How to Visualize Forecast Evaluation Results
Visualization
Use plot_calibration, plot_score_per_step, and plot_forecast to diagnose forecast accuracy and interval calibration visually.
-
How to Visualize Forecasts
Visualization
Plot point forecasts, compare multiple models, render prediction interval bands, inspect residual diagnostics, and check interval calibration.