nixtla is a Python client library for accessing Nixtla’s remotely hosted TimeGPT forecasting service. It requires an API key, sends data to external servers, and returns forecasting-related outputs without local model hardware. section 3.3
Use the client to:
- Initialize NixtlaClient after loading an API key from a .env file. section 3.3.1
- Plot single- or multiple-series data while mapping custom timestamp, identifier, and target columns. section 3.3.1
- Run cross-validation with optional fine-tuning and compare results with or without exogenous features. section 10.2.4
- Extract feature contributions and visualize Shapley values for individual forecasts. section 3.5.3
Minimal initialization
from dotenv import load_dotenv from nixtla import NixtlaClient load_dotenv() nixtla_client = NixtlaClient()
Listing 10.8 Cross-validating with TimeGPT
init = time()
timegpt_cv_fcsts = nixtla_client.cross_validation(
df=df,
h=HORIZON,
n_windows=N_WINDOWS,
finetune_steps=50, #1
finetune_loss="mae" #2
)
print(f"TimeGPT time: {time() - init} seconds")
timegpt_cv_fcsts.to_csv("timegpt_preds.csv", header=True, index=False)
Inspect a complete cross-validation call using a forecast horizon, rolling windows, fine-tuning steps, and MAE loss. section 10.2.4
