General Introduction
Kats is an open source toolkit developed by a team of researchers at Meta (formerly Facebook) and designed for time series analysis.Kats provides a lightweight, easy-to-use framework that covers everything from basic statistical analysis to sophisticated predictive modeling, anomaly detection, and feature extraction. Whether you are a data scientist or an engineer, Kats helps them process and gain insight into time series data more efficiently. It not only supports a wide range of models, but also provides rich tutorials and examples to help users get started quickly.
Function List
- Time series data analysis: Provide understanding and analysis of basic statistical characteristics.
- Change Point Detection: Identify change points in time series data.
- anomaly detection: Detect outliers in time series data.
- Trend forecasts: Use multiple models to predict future trends.
- Feature extraction and embedding: Extract useful features from time series data.
- multivariate analysis: Support for the analysis of multivariate time series data.
Using Help
Installation process
Kats can be installed via PyPI, here are the detailed installation steps:
- Update pip:
pip install --upgrade pip
- Install Kats:
pip install kats
- If you only need some of the features of Kats, you can install the lite version:
MINIMAL_KATS=1 pip install kats
Guidelines for use
Time series data analysis
- Import the necessary libraries and data:
import pandas as pd
from kats.consts import TimeSeriesData
from kats.models.prophet import ProphetModel, ProphetParams
# Read the data
air_passengers_df = pd.read_csv("path/to/air_passengers.csv", header=0, names=["time", "passengers"])
air_passengers_ts = TimeSeriesData(air_passengers_df)
- Create and train predictive models:
params = ProphetParams(seasonality_mode='multiplicative')
model = ProphetModel(air_passengers_ts, params)
model.fit()
- Make predictions:
forecast = model.predict(steps=30, freq="MS")
Change Point Detection
- Introducing change point detection algorithms:
from kats.detectors.cusum_detection import CUSUMDetector
# Simulate time series data
df_increase = pd.DataFrame({'time': pd.date_range('2019-01-01', '2019-03-01'), 'value': np.random.randn(60).cumsum()})
ts = TimeSeriesData(df_increase)
# Perform change point detection
detector = CUSUMDetector(ts)
change_points = detector.detector()
anomaly detection
- Import anomaly detection algorithms:
from kats.detectors.bocpd import BOCPDetector
# Anomaly detection using simulated data
detector = BOCPDetector(ts)
anomalies = detector.detector()
Recommendations for use
- Data Preprocessing: Ensure your time series data is clean and deal with any missing values or outliers to improve the accuracy of your analysis.
- Model selection: choose the right model according to the characteristics of your data. kats provides several models, you can find the most suitable one through experimentation.
- Visualization: Use Kats' built-in visualization capabilities to understand data patterns and model performance, which is useful when analyzing and reporting results.
- Performance Evaluation: Evaluate the performance of different models and select the best hyperparameters before applying the model.
Handling of common problems
- Installation issues: If you encounter dependency conflicts during installation, try installing in a virtual environment or check out the FAQ on Kats' official GitHub page.
- Data format issues: If your data format is different from what Kats expects, it may cause an error. Make sure your data column names are correct and that the data types are as required.
- Performance issues: for large-scale datasets, consider data sampling or use more efficient models to reduce computation time.