Browse the glossary using this index

Special | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | ALL

K

Picture of Yee Wei Law

Kats by Facebook Research

by Yee Wei Law - Saturday, 29 June 2024, 11:22 PM
 

Facebook Research’s Kats has been billed as “one-stop shop for time series analysis in Python”. Kats supports standard time-series analyses, e.g., forecasting, anomaly/outlier detection.

The official installation instructions however do not work out of the box. At the time of writing, the official instructions lead to the error message “python setup.py bdist_wheel did not run successfully” due to incompatibility with the latest version of Python.

Based on community responses to the error message, and based on my personal experience, the following instructions work:

conda install python=3.7 pip setuptools ephem pystan fbprophet
pip install kats
pip install packaging==21.3

The following sample code should run error-free:

import numpy as np
import pandas as pd

from kats.consts import TimeSeriesData
from kats.detectors.cusum_detection import CUSUMDetector

# simulate time series with increase
np.random.seed(10)
df_increase = pd.DataFrame(
    {
        'time': pd.date_range('2019-01-01', '2019-03-01'),
        'increase':np.concatenate([np.random.normal(1,0.2,30), np.random.normal(2,0.2,30)]),
    }
)

# convert to TimeSeriesData object
timeseries = TimeSeriesData(df_increase)

# run detector and find change points
change_points = CUSUMDetector(timeseries).detector()