Skip to content
Log inGet startedHugging FaceGitHub

Tools

Plots

yhatlabs.plots draws every result with matplotlib (pip install "yhatlabs[plot]"). Each function returns the Figure, so .savefig(...) or further styling works as usual.

from yhatlabs import plots
Function Draws Also as
plots.forecast(fc, history=df) the median and every interval as nested bands, after the history fc.plot(...)
plots.backtest(ev) actuals across the windows, each window’s forecast, the cutoffs ev.plot()
plots.calibration(ev) forecast quantiles: nominal level against the share of actuals below it ev.plot_calibration()
plots.anomalies(flags) the series, its expected range and the flagged points
plots.scenarios(sc, history=df) one line and band per scenario
plots.reliability(ev) classification: predicted probability against observed frequency ev.plot() on a table evaluation
plots.predicted_vs_actual(res, y) regression: predictions against true values, with interval bars ev.plot() on a regression evaluation
plots.importance(imp) permutation importance bars with their spread
plots.effect(eff) an effect curve: the average prediction and the spread across rows

The forecast plots take ids=[...] or max_series= (default 4) to choose which series to draw, and ax= to draw into your own axes.

Forecast with nested 50% and 80% bands after the history

fc.plot(history=df): the history in grey, then the median forecast with its 50% and 80% intervals as nested bands; the darker band is where the actual is more likely to land.

Backtest windows with cutoffs

ev.plot(): a backtest. The dark line is what happened; each blue block is a forecast made at the dotted cutoff, without seeing anything after it. Actuals outside the bands are misses.

Anomalies: expected range and flagged points

plots.anomalies(flags): the shaded band is the range the model expected each point in (q10 to q90 of a forecast made just before it); red points are the readings flagged as anomalies.

Reliability diagram

plots.reliability(ev): are the probabilities honest? Each point groups the rows given a similar probability and plots how often the event happened. On the dashed diagonal, a 70% means 70%.

Predicted against actual with intervals

plots.predicted_vs_actual(res, y): each dot is a row, predicted against true; the bars are its 90% interval. Close to the dashed diagonal is accurate, and a bar crossing it means the interval held the true value.

Importance bars

plots.importance(imp): how much the score drops when a column’s values are shuffled. Longer bars are columns the model relies on more; the black line is the spread over repeats.

Effect curve

plots.effect(eff): how the prediction moves as one column changes, everything else as in real rows. The line is the average; the band shows how much that differs between rows.

The code for each is on the page of the feature: Forecasting, Backtesting, Anomalies, Evaluating on your data, Effects.