MCPcopy
hub / github.com/facebook/prophet / add_changepoints_to_plot

Function add_changepoints_to_plot

python/prophet/plot.py:444–475  ·  view source on GitHub ↗

Add markers for significant changepoints to prophet forecast plot. Example: fig = m.plot(forecast) add_changepoints_to_plot(fig.gca(), m, forecast) Parameters ---------- ax: axis on which to overlay changepoint markers. m: Prophet model. fcst: Forecast output from m

(
    ax, m, fcst, threshold=0.01, cp_color='r', cp_linestyle='--', trend=True,
)

Source from the content-addressed store, hash-verified

442
443
444def add_changepoints_to_plot(
445 ax, m, fcst, threshold=0.01, cp_color='r', cp_linestyle='--', trend=True,
446):
447 """Add markers for significant changepoints to prophet forecast plot.
448
449 Example:
450 fig = m.plot(forecast)
451 add_changepoints_to_plot(fig.gca(), m, forecast)
452
453 Parameters
454 ----------
455 ax: axis on which to overlay changepoint markers.
456 m: Prophet model.
457 fcst: Forecast output from m.predict.
458 threshold: Threshold on trend change magnitude for significance.
459 cp_color: Color of changepoint markers.
460 cp_linestyle: Linestyle for changepoint markers.
461 trend: If True, will also overlay the trend.
462
463 Returns
464 -------
465 a list of matplotlib artists
466 """
467 artists = []
468 if trend:
469 artists.append(ax.plot(fcst['ds'], fcst['trend'], c=cp_color))
470 signif_changepoints = m.changepoints[
471 np.abs(np.nanmean(m.params['delta'], axis=0)) >= threshold
472 ] if len(m.changepoints) > 0 else []
473 for cp in signif_changepoints:
474 artists.append(ax.axvline(x=cp, c=cp_color, ls=cp_linestyle))
475 return artists
476
477
478def plot_cross_validation_metric(

Callers

nothing calls this directly

Calls 1

plotMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…