Top Related Projects
Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.
A Python package for Bayesian forecasting with object-oriented design and probabilistic models under the hood.
A unified framework for machine learning with time series
Scalable and user friendly neural :brain: forecasting algorithms.
NeuralProphet: A simple forecasting package
Quick Overview
Greykite is an open-source library for time series forecasting developed by LinkedIn. It provides flexible and intuitive interfaces for forecasting, with a focus on interpretability and ease of use. The library offers a range of forecasting models and techniques, including Silverkite, a novel forecasting algorithm developed by LinkedIn.
Pros
- Highly flexible and customizable forecasting framework
- Strong focus on interpretability and explainability of forecasts
- Includes advanced features like automatic hyperparameter tuning and cross-validation
- Supports both univariate and multivariate time series forecasting
Cons
- Steeper learning curve compared to some simpler forecasting libraries
- Documentation can be overwhelming for beginners
- Limited community support compared to more established forecasting libraries
- Primarily focused on Python, with limited support for other languages
Code Examples
- Simple forecasting with Silverkite:
from greykite.framework.templates.autogen.forecast_config import ForecastConfig
from greykite.framework.templates.forecaster import Forecaster
forecaster = Forecaster()
result = forecaster.run_forecast_config(
df=df,
config=ForecastConfig(
model_template="SILVERKITE",
forecast_horizon=30
)
)
- Customizing the forecasting model:
from greykite.framework.templates.model_templates import ModelTemplateEnum
result = forecaster.run_forecast_config(
df=df,
config=ForecastConfig(
model_template=ModelTemplateEnum.SILVERKITE.name,
model_components={
"seasonality": {
"auto_seasonality": False,
"yearly_seasonality": 12,
"quarterly_seasonality": 4,
},
"growth": {
"growth_term": "linear"
}
},
forecast_horizon=30
)
)
- Evaluating forecast performance:
from greykite.framework.templates.autogen.forecast_config import EvaluationMetricEnum
result = forecaster.run_forecast_config(
df=df,
config=ForecastConfig(
model_template="SILVERKITE",
evaluation_metric=EvaluationMetricEnum.MeanAbsolutePercentageError,
evaluation_period="30D",
forecast_horizon=30
)
)
print(f"MAPE: {result.forecast.model_summary.evaluation_scores['MAPE']}")
Getting Started
To get started with Greykite, follow these steps:
- Install the library:
pip install greykite
- Import necessary modules and prepare your data:
import pandas as pd
from greykite.framework.templates.autogen.forecast_config import ForecastConfig
from greykite.framework.templates.forecaster import Forecaster
# Prepare your time series data
df = pd.read_csv("your_data.csv")
df["timestamp"] = pd.to_datetime(df["timestamp"])
- Create a forecaster and run a simple forecast:
forecaster = Forecaster()
result = forecaster.run_forecast_config(
df=df,
time_col="timestamp",
value_col="value",
config=ForecastConfig(
model_template="SILVERKITE",
forecast_horizon=30
)
)
# Plot the forecast
result.forecast.plot()
Competitor Comparisons
Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.
Pros of Prophet
- More established and widely adopted in the data science community
- Extensive documentation and tutorials available
- Handles seasonality and holidays automatically
Cons of Prophet
- Less flexible for complex time series patterns
- Can be slower for large datasets
- Limited support for external regressors
Code Comparison
Prophet:
from fbprophet import Prophet
model = Prophet()
model.fit(df)
future = model.make_future_dataframe(periods=365)
forecast = model.predict(future)
Greykite:
from greykite.framework.templates.autogen.forecast_config import ForecastConfig
from greykite.framework.templates.forecaster import Forecaster
forecaster = Forecaster()
result = forecaster.run_forecast_config(
df,
config=ForecastConfig(
model_template="SILVERKITE",
forecast_horizon=365
)
)
Both libraries offer straightforward APIs for time series forecasting. Prophet focuses on simplicity and automatic handling of common time series components. Greykite provides more flexibility and customization options, allowing users to fine-tune their models for complex scenarios.
While Prophet is more widely adopted and has extensive documentation, Greykite offers advanced features like automatic model selection and flexible seasonality modeling. The choice between the two depends on the specific requirements of the forecasting task and the user's familiarity with time series analysis.
A Python package for Bayesian forecasting with object-oriented design and probabilistic models under the hood.
Pros of Orbit
- More flexible modeling approach with support for various probabilistic models
- Better handling of uncertainty and confidence intervals
- Stronger support for Bayesian inference techniques
Cons of Orbit
- Steeper learning curve due to more complex API
- Less focus on automated forecasting pipelines
- Fewer built-in evaluation metrics compared to Greykite
Code Comparison
Orbit example:
from orbit.models import DLT
model = DLT(
response_col='y',
date_col='ds',
regressor_col=['regressor1', 'regressor2']
)
model.fit(df)
Greykite example:
from greykite.framework.templates.autogen.forecast_config import ForecastConfig
from greykite.framework.templates.forecaster import Forecaster
forecaster = Forecaster()
result = forecaster.run_forecast_config(
df,
config=ForecastConfig(
model_template="SILVERKITE",
forecast_horizon=30
)
)
Both libraries offer powerful time series forecasting capabilities, but Orbit provides more flexibility for advanced users, while Greykite focuses on ease of use and automated forecasting workflows. Orbit excels in uncertainty quantification and Bayesian methods, whereas Greykite offers a more streamlined approach with built-in templates and evaluation metrics.
A unified framework for machine learning with time series
Pros of sktime
- More comprehensive, covering a wider range of time series tasks beyond forecasting
- Larger community and more frequent updates
- Scikit-learn compatible API, making it easier to integrate with existing ML workflows
Cons of sktime
- Steeper learning curve due to its broader scope
- May be overkill for simple forecasting tasks
- Less focus on automated forecasting compared to Greykite
Code Comparison
sktime example:
from sktime.forecasting.arima import ARIMA
from sktime.datasets import load_airline
y = load_airline()
forecaster = ARIMA(order=(1, 1, 1), seasonal_order=(1, 1, 1, 12))
forecaster.fit(y)
y_pred = forecaster.predict(fh=[1, 2, 3])
Greykite example:
from greykite.framework.templates.autogen.forecast_config import ForecastConfig
from greykite.framework.templates.forecaster import Forecaster
forecaster = Forecaster()
result = forecaster.run_forecast_config(
df=df,
config=ForecastConfig(
model_template="SILVERKITE",
forecast_horizon=30
)
)
Scalable and user friendly neural :brain: forecasting algorithms.
Pros of neuralforecast
- Focuses on neural network-based forecasting models, offering a wider range of deep learning approaches
- Provides GPU acceleration for faster training and inference
- Includes built-in support for probabilistic forecasting
Cons of neuralforecast
- Less emphasis on traditional statistical models compared to greykite
- May require more computational resources for complex neural network models
- Steeper learning curve for users unfamiliar with deep learning concepts
Code Comparison
greykite example:
from greykite.framework.templates.autogen.forecast_config import ForecastConfig
from greykite.framework.templates.forecaster import Forecaster
forecaster = Forecaster()
result = forecaster.run_forecast_config(
df=df,
config=ForecastConfig(
model_template="SILVERKITE",
forecast_horizon=30
)
)
neuralforecast example:
from neuralforecast import NeuralForecast
from neuralforecast.models import NHITS
model = NeuralForecast(
models=[NHITS(input_size=30, h=7, loss="MSE")],
freq="D"
)
model.fit(df)
forecast = model.predict()
Both libraries offer time series forecasting capabilities, but neuralforecast specializes in neural network-based models, while greykite provides a broader range of traditional and modern forecasting techniques. The choice between them depends on the specific use case, available computational resources, and the user's familiarity with different forecasting approaches.
NeuralProphet: A simple forecasting package
Pros of Neural Prophet
- Incorporates deep learning techniques, allowing for more complex patterns and non-linear relationships
- Offers automatic seasonality detection and handling
- Provides built-in support for external regressors and lagged variables
Cons of Neural Prophet
- May require more computational resources and training time
- Less interpretable compared to traditional statistical models
- Potentially more prone to overfitting, especially with limited data
Code Comparison
Neural Prophet:
from neuralprophet import NeuralProphet
model = NeuralProphet()
model.fit(df)
future = model.make_future_dataframe(df, periods=30)
forecast = model.predict(future)
Greykite:
from greykite.framework.templates.autogen.forecast_config import ForecastConfig
from greykite.framework.templates.forecaster import Forecaster
forecaster = Forecaster()
result = forecaster.run_forecast_config(
df,
config=ForecastConfig(
model_template="SILVERKITE",
forecast_horizon=30
)
)
Both libraries offer high-level APIs for time series forecasting, but Neural Prophet focuses on neural network-based approaches, while Greykite provides a more traditional statistical framework with additional flexibility and interpretability.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Greykite: A flexible, intuitive and fast forecasting and anomaly detection library
.. raw:: html
Why Greykite?
The Greykite library provides flexible, intuitive and fast forecasts through its flagship algorithm, Silverkite.
Silverkite algorithm works well on most time series, and is especially adept for those with changepoints in trend or seasonality, event/holiday effects, and temporal dependencies. Its forecasts are interpretable and therefore useful for trusted decision-making and insights.
The Greykite library provides a framework that makes it easy to develop a good forecast model, with exploratory data analysis, outlier/anomaly preprocessing, feature extraction and engineering, grid search, evaluation, benchmarking, and plotting. Other open source algorithms can be supported through Greykiteâs interface to take advantage of this framework, as listed below.
Greykite AD (Anomaly Detection) is an extension of the Greykite Forecasting library. It provides users with an interpretable, fast, robust and easy to use interface to monitor their metrics with minimal effort.
Greykite AD improves upon the out-of-box confidence intervals generated by Silverkite, by automatically tuning the confidence intervals
and other filters (e.g. based on APE
) using expected alert rate information and/ or anomaly labels, if available.
It allows the users to define robust objective function, constraints and parameter space to optimize the confidence intervals.
For example user can target a minimal recall level of 80% while maximizing precision. Additionally, the users can specify a
minimum error level to filter out anomalies that are not business relevant. The motivation to include criteria other than
statistical significance is to bake in material/ business impact into the detection.
For a demo, please see our quickstart <https://linkedin.github.io/greykite/get_started>
_.
Distinguishing Features
- Flexible design
- Provides time series regressors to capture trend, seasonality, holidays, changepoints, and autoregression, and lets you add your own.
- Fits the forecast using a machine learning model of your choice.
- Intuitive interface
- Provides powerful plotting tools to explore seasonality, interactions, changepoints, etc.
- Provides model templates (default parameters) that work well based on data characteristics and forecast requirements (e.g. daily long-term forecast).
- Produces interpretable output, with model summary to examine individual regressors, and component plots to visually inspect the combined effect of related regressors.
- Fast training and scoring
- Facilitates interactive prototyping, grid search, and benchmarking. Grid search is useful for model selection and semi-automatic forecasting of multiple metrics.
- Extensible framework
- Exposes multiple forecast algorithms in the same interface, making it easy to try algorithms from different libraries and compare results.
- The same pipeline provides preprocessing, cross-validation, backtest, forecast, and evaluation with any algorithm.
Algorithms currently supported within Greykiteâs modeling framework:
- Silverkite (Greykiteâs flagship forecasting algorithm)
- Greykite Anomaly Detection (Greykite's flagship anomaly detection algorithm)
Facebook Prophet <https://facebook.github.io/prophet/>
_Auto Arima <https://alkaline-ml.com/pmdarima/>
_
Notable Components
Greykite offers components that could be used within other forecasting libraries or even outside the forecasting context.
- ModelSummary() - R-like summaries of
scikit-learn
andstatsmodels
regression models. - ChangepointDetector() - changepoint detection based on adaptive lasso, with visualization.
- SimpleSilverkiteForecast() - Silverkite algorithm with
forecast_simple
andpredict
methods. - SilverkiteForecast() - low-level interface to Silverkite algorithm with
forecast
andpredict
methods. - ReconcileAdditiveForecasts() - adjust a set of forecasts to satisfy inter-forecast additivity constraints.
- GreykiteDetector() - simple interface for optimizing anomaly detection performance based on Greykite forecasts.
Usage Examples
You can obtain forecasts with only a few lines of code:
.. code-block:: python
from greykite.common.data_loader import DataLoader
from greykite.framework.templates.autogen.forecast_config import ForecastConfig
from greykite.framework.templates.autogen.forecast_config import MetadataParam
from greykite.framework.templates.forecaster import Forecaster
from greykite.framework.templates.model_templates import ModelTemplateEnum
# Defines inputs
df = DataLoader().load_bikesharing().tail(24*90) # Input time series (pandas.DataFrame)
config = ForecastConfig(
metadata_param=MetadataParam(time_col="ts", value_col="count"), # Column names in `df`
model_template=ModelTemplateEnum.AUTO.name, # AUTO model configuration
forecast_horizon=24, # Forecasts 24 steps ahead
coverage=0.95, # 95% prediction intervals
)
# Creates forecasts
forecaster = Forecaster()
result = forecaster.run_forecast_config(df=df, config=config)
# Accesses results
result.forecast # Forecast with metrics, diagnostics
result.backtest # Backtest with metrics, diagnostics
result.grid_search # Time series CV result
result.model # Trained model
result.timeseries # Processed time series with plotting functions
For a demo, please see our quickstart <https://linkedin.github.io/greykite/get_started>
_.
Setup and Installation
Greykite is available on Pypi and can be installed with pip:
.. code-block::
pip install greykite
For more installation tips, see installation <http://linkedin.github.io/greykite/installation>
_.
Documentation
Please find our full documentation here <http://linkedin.github.io/greykite/docs>
_.
Learn More
Website <https://linkedin.github.io/greykite>
_Paper <https://doi.org/10.1145/3534678.3539165>
_ (KDD '22 Best Paper Runner-up, Applied Data Science Track)Blog post <https://engineering.linkedin.com/blog/2021/greykite--a-flexible--intuitive--and-fast-forecasting-library>
_
Citation
Please cite Greykite in your publications if it helps your research:
.. code-block::
@misc{reza2021greykite-github,
author = {Reza Hosseini and
Albert Chen and
Kaixu Yang and
Sayan Patra and
Yi Su and
Rachit Arora},
title = {Greykite: a flexible, intuitive and fast forecasting library},
url = {https://github.com/linkedin/greykite},
year = {2021}
}
.. code-block::
@inproceedings{reza2022greykite-kdd,
author = {Hosseini, Reza and Chen, Albert and Yang, Kaixu and Patra, Sayan and Su, Yi and Al Orjany, Saad Eddin and Tang, Sishi and Ahammad, Parvez},
title = {Greykite: Deploying Flexible Forecasting at Scale at LinkedIn},
year = {2022},
isbn = {9781450393850},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/3534678.3539165},
doi = {10.1145/3534678.3539165},
booktitle = {Proceedings of the 28th ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
pages = {3007â3017},
numpages = {11},
keywords = {forecasting, scalability, interpretable machine learning, time series},
location = {Washington DC, USA},
series = {KDD '22}
}
License
Copyright (c) LinkedIn Corporation. All rights reserved. Licensed under the
BSD 2-Clause <https://opensource.org/licenses/BSD-2-Clause>
_ License.
Top Related Projects
Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.
A Python package for Bayesian forecasting with object-oriented design and probabilistic models under the hood.
A unified framework for machine learning with time series
Scalable and user friendly neural :brain: forecasting algorithms.
NeuralProphet: A simple forecasting package
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot