The way to Construct a Forecasting Pipeline with TimeCopilot Utilizing Basis Fashions and Automated Anomaly Detection

The way to Construct a Forecasting Pipeline with TimeCopilot Utilizing Basis Fashions and Automated Anomaly Detection


import os, warnings
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
warnings.filterwarnings("ignore")
pd.set_option("show.width", 160)
pd.set_option("show.max_columns", 30)
print("numpy:", np.__version__)
import scipy; print("scipy:", scipy.__version__)
strive:
   import torch
   HAS_GPU = torch.cuda.is_available()
besides Exception:
   HAS_GPU = False
print(f"GPU obtainable: {HAS_GPU}")
df = pd.read_csv(
   "https://timecopilot.s3.amazonaws.com/public/information/air_passengers.csv",
   parse_dates=["ds"],
)
df["unique_id"] = df["unique_id"].astype(str)
rng = np.random.default_rng(7)
dates = df["ds"].distinctive(); n = len(dates)
synth = pd.DataFrame({
   "unique_id": "Artificial",
   "ds": dates,
   "y": (np.linspace(50, 250, n)
         + 40 * np.sin(2 * np.pi * np.arange(n) / 12)
         + rng.regular(0, 8, n)).spherical(2),
})
anomaly_idx = [30, 75, 120]
synth.loc[anomaly_idx, "y"] *= 2.2
panel = pd.concat([df[["unique_id", "ds", "y"]], synth], ignore_index=True)
print("nPanel form:", panel.form)
print(panel.groupby("unique_id")["y"].agg(["count", "mean", "min", "max"]))
H, FREQ = 12, "MS"



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *