Code Monkey home page Code Monkey logo

swimmingcreative / kats Goto Github PK

View Code? Open in Web Editor NEW

This project forked from facebookresearch/kats

0.0 1.0 0.0 13.29 MB

Kats, a kit to analyze time series data, a lightweight, easy-to-use, generalizable, and extendable framework to perform time series analysis, from understanding the key statistics and characteristics, detecting change points and anomalies, to forecasting future trends.

License: MIT License

Python 38.31% Jupyter Notebook 61.25% Makefile 0.02% Batchfile 0.19% CSS 0.02% HTML 0.21%

kats's Introduction

Description

Kats is a toolkit to analyze time series data, a lightweight, easy-to-use, and generalizable framework to perform time series analysis. Time series analysis is an essential component of Data Science and Engineering work at industry, from understanding the key statistics and characteristics, detecting regressions and anomalies, to forecasting future trends. Kats aims to provide the one-stop shop for time series analysis, including detection, forecasting, feature extraction/embedding, multivariate analysis, etc.

Kats is released by Facebook's Infrastructure Data Science team. It is available for download on PyPI.

Important links

Installation in Python

Kats is on PyPI, so you can use pip to install it.

pip install --upgrade pip
pip install kats

If you need only a small subset of Kats, you can install a minimal version of Kats with

MINIMAL=1 pip install kats

which omits many dependencies (everything in test_requirements.txt). However, this will disable many functionalities and cause import kats to log warnings. See setup.py for full details and options.

Examples

Here are a few sample snippets from a subset of Kats offerings:

Forecasting

Using Prophet model to forecast the air_passengers data set.

import pandas as pd

from kats.consts import TimeSeriesData
from kats.models.prophet import ProphetModel, ProphetParams

# take `air_passengers` data as an example
air_passengers_df = pd.read_csv(
    "../kats/data/air_passengers.csv",
    header=0,
    names=["time", "passengers"],
)

# convert to TimeSeriesData object
air_passengers_ts = TimeSeriesData(air_passengers_df)

# create a model param instance
params = ProphetParams(seasonality_mode='multiplicative') # additive mode gives worse results

# create a prophet model instance
m = ProphetModel(air_passengers_ts, params)

# fit model simply by calling m.fit()
m.fit()

# make prediction for next 30 month
fcst = m.predict(steps=30, freq="MS")

Detection

Using CUSUM detection algorithm on simulated data set.

# import packages
import numpy as np

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()

TSFeatures

We can extract meaningful features from the given time series data

# Initiate feature extraction class
from kats.tsfeatures.tsfeatures import TsFeatures

# take `air_passengers` data as an example
air_passengers_df = pd.read_csv(
    "../kats/data/air_passengers.csv",
    header=0,
    names=["time", "passengers"],
)

# convert to TimeSeriesData object
air_passengers_ts = TimeSeriesData(air_passengers_df)

# calculate the TsFeatures
features = TsFeatures().transform(air_passengers_ts)

Changelog

Version 0.1.0

  • Initial release

Contributors

Kats is a project with several skillful researchers and engineers contributing to it.

Kats is currently maintained by Xiaodong Jiang with major contributions coming from many talented individuals in various forms and means. A non-exhaustive but growing list needs to mention: Sudeep Srivastava, Sourav Chatterjee, Jeff Handler, Rohan Bopardikar, Dawei Li, Yanjun Lin, Yang Yu, Michael Brundage, Caner Komurlu, Rakshita Nagalla, Zhichao Wang, Hechao Sun, Peng Gao, Wei Cheung, Jun Gao, Qi Wang, Morteza Kazemi, Tihamér Levendovszky, Jian Zhang, Ahmet Koylan, Kun Jiang, Aida Shoydokova, Ploy Temiyasathit, Sean Lee, Nikolay Pavlovich Laptev, Peiyi Zhang, Emre Yurtbay, Daniel Dequech, Rui Yan, and William Luo.

License

Kats is licensed under the MIT license.

kats's People

Contributors

michaelbrundage avatar iamxiaodong avatar rohanfb avatar facebook-github-bot avatar ahmetburhanfb avatar bigfootjon avatar mariusguerard avatar r-barnes avatar axemen avatar clumdee avatar yangbk560 avatar wzcfb avatar weizhic avatar omrihaber avatar mdhiman avatar uthakore avatar mjt91 avatar itsmrlin avatar jeffhandl avatar yuhc avatar superzgc avatar ahmetburhan avatar ad1407 avatar adiellm avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.