Replies: 1 comment
-
I was able to get a plot using Jupyter notebook but not Jupyter Lab. I'm going to troubleshoot why and if if how I can see the plots in an interactive terminal in the Jupyter lab. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I combined the 2 code snippets in the read.me, not getting any errors (just a warning about resume_download) but I'm not getting any output? Any ideas? Here is the code:
import pandas as pd # requires: pip install pandas
import matplotlib.pyplot as plt # requires: pip install matplotlib
import numpy as np
import torch
from chronos import ChronosPipeline
pipeline = ChronosPipeline.from_pretrained(
"amazon/chronos-t5-small",
device_map="cuda", # use "cpu" for CPU inference and "mps" for Apple Silicon
torch_dtype=torch.bfloat16,
)
df = pd.read_csv("https://raw.githubusercontent.com/AileenNielsen/TimeSeriesAnalysisWithPython/master/data/AirPassengers.csv")
forecast = pipeline.predict(
context=torch.tensor(df["#Passengers"]),
prediction_length=12,
num_samples=20,
)
forecast_index = range(len(df), len(df) + 12)
print(forecast_index)
low, median, high = np.quantile(forecast[0].numpy(), [0.1, 0.5, 0.9], axis=0)
plt.figure(figsize=(8, 4))
plt.plot(df["#Passengers"], color="royalblue", label="historical data")
plt.plot(forecast_index, median, color="tomato", label="median forecast")
plt.fill_between(forecast_index, low, high, color="tomato", alpha=0.3, label="80% prediction interval")
plt.legend()
plt.grid()
plt.show()
Beta Was this translation helpful? Give feedback.
All reactions