8000 how to plot fan chart using VAR? · sktime sktime · Discussion #6753 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

how to plot fan chart using VAR? #6753

Answered by SultanOrazbayev
sakaiando asked this question in Q&A
Discussion options

You must be logged in to vote

Hello, Sakai!

The issue here is at how pandas treats levels of a DataFrame. Here's the way to solve it:

import numpy as np
import pandas as pd
from sktime.forecasting.var import VAR
from sktime.utils.plotting import plot_series

y_train = pd.DataFrame(np.random.rand(1000, 3), columns=["x1", "x2", "x3"])
forecaster = VAR(maxlags=1)
forecaster.fit(y_train)
y_pred = forecaster.predict(fh=range(1, 100))
coverage = 0.9
y_pred_ints1 = forecaster.predict_interval(coverage=coverage)
variable_to_plot = "x1"
pred_interval = y_pred_ints1[[variable_to_plot]].copy()
pred_interval.columns = pred_interval.columns.remove_unused_levels()
plot_series(y_train[[variable_to_plot]], y_pred[[variable_to_plot]], p…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sakaiando
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
module:datatypes datatypes module: data containers, checkers & converters module:plotting&utilities utilities including plottinng
2 participants
0