Quickstart

Get started in a ready-to-use environment

Click below to open this Quickstart in Google Colab and run the code examples interactively:

Historical anomaly detection plot illustrating anomalies

Overview
Use the detect_anomalies method to perform historical anomaly detection and the plot method to visualize the identified anomalies in your time series data.

Key Concept

  • Quickly detect anomalies in your historical time series data.

  • Visualize outliers for better understanding and faster decision-making.

Steps to Detect Anomalies

1

1. Install and Import Packages

Import Packages
import pandas as pd
from nixtla import NixtlaClient
2

2. Initialize Nixtla Client

Initialize NixtlaClient
nixtla_client = NixtlaClient(
    # defaults to os.environ.get("NIXTLA_API_KEY")
    api_key='my_api_key_provided_by_nixtla'
)
3

3. Read the Dataset

Load Dataset
# Read the dataset
df = pd.read_csv('https://datasets-nixtla.s3.amazonaws.com/peyton-manning.csv')
4

4. Detect Anomalies

Detect Anomalies
# Detect anomalies
anomalies_df = nixtla_client.detect_anomalies(
    df,
    freq='D'
)
5

5. Plot Anomalies

Plot Anomalies
# Plot anomalies
nixtla_client.plot(
    df,
    anomalies_df
)
6

6. View Logs (optional)

Next Steps

For more details about historical anomaly detection with TimeGPT, see our in-depth tutorial. This tutorial covers additional configurations and best practices for analyzing time series data at scale.