Convert Figma logo to code with AI

uber logoorbit

A Python package for Bayesian forecasting with object-oriented design and probabilistic models under the hood.

1,853
132
1,853
50

Top Related Projects

18,260

Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.

Statsmodels: statistical modeling and econometrics in Python

7,734

A unified framework for machine learning with time series

15,551

Topic Modelling for Humans

A flexible, intuitive and fast forecasting library

A statistical library designed to fill the void in Python's time series analysis capabilities, including the equivalent of R's auto.arima function.

Quick Overview

Orbit is an open-source Python package developed by Uber for Bayesian time series modeling and forecasting. It provides a flexible framework for various time series analysis tasks, including trend forecasting, seasonality detection, and causal impact analysis, using probabilistic models and Bayesian inference.

Pros

  • Flexible and extensible framework for time series modeling
  • Supports both traditional and modern Bayesian inference methods
  • Includes built-in visualization tools for model diagnostics and results
  • Integrates well with popular data science libraries like pandas and NumPy

Cons

  • Steeper learning curve compared to some simpler forecasting libraries
  • Documentation could be more comprehensive for advanced use cases
  • Limited support for non-Bayesian time series methods
  • May be computationally intensive for very large datasets

Code Examples

  1. Basic time series forecasting:
from orbit.models import DLT

# Prepare your data
df = pd.read_csv('your_data.csv')

# Initialize and fit the model
model = DLT(response_col='y', date_col='ds')
model.fit(df)

# Make predictions
predictions = model.predict(df)
  1. Seasonality detection:
from orbit.models import ETS

# Initialize model with weekly seasonality
model = ETS(
    response_col='y',
    date_col='ds',
    seasonality=52
)

# Fit the model and extract seasonal components
model.fit(df)
seasonal_components = model.extract_seasonality(df)
  1. Causal impact analysis:
from orbit.models import DLT

# Prepare pre and post-intervention data
pre_data = pd.read_csv('pre_intervention.csv')
post_data = pd.read_csv('post_intervention.csv')

# Fit the model on pre-intervention data
model = DLT(response_col='y', date_col='ds')
model.fit(pre_data)

# Predict counterfactual and compare with actual post-intervention data
impact = model.predict(post_data)

Getting Started

To get started with Orbit, follow these steps:

  1. Install Orbit:
pip install orbit-ml
  1. Import necessary modules:
import pandas as pd
from orbit.models import DLT
from orbit.diagnostics.plot import plot_predicted_data
  1. Load your data and create a simple model:
df = pd.read_csv('your_data.csv')
model = DLT(response_col='y', date_col='ds')
model.fit(df)
predictions = model.predict(df)
plot_predicted_data(predictions, title='My First Orbit Forecast')

Competitor Comparisons

18,260

Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.

Pros of Prophet

  • More user-friendly and accessible for non-experts
  • Handles missing data and outliers automatically
  • Extensive documentation and community support

Cons of Prophet

  • Less flexible for custom model specifications
  • May overfit on datasets with limited historical data
  • Performance can be slower for large-scale forecasting tasks

Code Comparison

Prophet:

from fbprophet import Prophet
model = Prophet()
model.fit(df)
future = model.make_future_dataframe(periods=365)
forecast = model.predict(future)

Orbit:

from orbit.models import DLT
model = DLT(response_col='y', date_col='ds')
model.fit(df)
prediction = model.predict(df)

Key Differences

  • Prophet focuses on ease of use and automatic feature handling
  • Orbit offers more customization options for advanced users
  • Prophet uses a decomposable time series model
  • Orbit implements various time series models, including Bayesian techniques

Use Cases

  • Prophet: Quick forecasting for business metrics with seasonal patterns
  • Orbit: Complex time series analysis with custom model requirements

Both libraries provide valuable tools for time series forecasting, with Prophet emphasizing simplicity and Orbit offering more flexibility for advanced users.

Statsmodels: statistical modeling and econometrics in Python

Pros of statsmodels

  • Comprehensive statistical library with a wide range of models and methods
  • Well-established and extensively documented
  • Integrates seamlessly with NumPy and pandas

Cons of statsmodels

  • Steeper learning curve for beginners
  • Less focus on time series forecasting compared to Orbit
  • May require more code for specific time series tasks

Code Comparison

statsmodels:

import statsmodels.api as sm
model = sm.tsa.SARIMAX(data, order=(1, 1, 1), seasonal_order=(1, 1, 1, 12))
results = model.fit()
forecast = results.forecast(steps=30)

Orbit:

from orbit.models import DLT
model = DLT(response_col='y', date_col='ds')
model.fit(df)
predicted_df = model.predict(df)

statsmodels offers a more general-purpose statistical toolkit, while Orbit specializes in time series forecasting with a focus on interpretability and ease of use. statsmodels provides a broader range of statistical models and methods, making it suitable for various analytical tasks. However, Orbit's simplified API and built-in visualization tools make it more accessible for time series forecasting tasks, especially for those new to the field.

7,734

A unified framework for machine learning with time series

Pros of sktime

  • Broader scope, covering various time series tasks beyond forecasting
  • More extensive documentation and tutorials
  • Larger community and more frequent updates

Cons of sktime

  • Steeper learning curve due to its comprehensive nature
  • May be overkill for simple forecasting tasks
  • Less focus on Bayesian methods compared to Orbit

Code Comparison

sktime example:

from sktime.forecasting.arima import ARIMA
forecaster = ARIMA(order=(1, 1, 1))
forecaster.fit(y_train)
y_pred = forecaster.predict(fh=[1, 2, 3])

Orbit example:

from orbit.models import DLT
model = DLT(response_col='y', date_col='ds')
model.fit(df)
predicted_df = model.predict(df)

Both libraries offer intuitive APIs for time series forecasting, but sktime provides a more standardized interface across different algorithms, while Orbit focuses on Bayesian structural time series models with a simpler API for specific use cases.

15,551

Topic Modelling for Humans

Pros of Gensim

  • Broader scope: Gensim is a comprehensive library for topic modeling, document indexing, and similarity retrieval
  • Mature project: Established in 2009, it has a large user base and extensive documentation
  • Supports various algorithms: Includes LSA, LDA, word2vec, and more for diverse NLP tasks

Cons of Gensim

  • Less focused on time series: While versatile, it's not specifically designed for time series forecasting
  • Steeper learning curve: Due to its broad functionality, it may take longer to master for specific use cases

Code Comparison

Gensim (topic modeling):

from gensim import corpora, models
dictionary = corpora.Dictionary(texts)
corpus = [dictionary.doc2bow(text) for text in texts]
lda_model = models.LdaMulticore(corpus=corpus, num_topics=10)

Orbit (time series forecasting):

from orbit.models import DLT
model = DLT(response_col='response', date_col='date')
model.fit(df)
predicted_df = model.predict(df)

Summary

Gensim excels in general NLP tasks and topic modeling, offering a wide range of algorithms and techniques. Orbit, on the other hand, specializes in time series forecasting with a focus on Bayesian models. While Gensim provides more versatility for text analysis, Orbit offers a more streamlined approach for time-based predictions.

A flexible, intuitive and fast forecasting library

Pros of Greykite

  • More flexible and customizable forecasting models
  • Better handling of complex seasonality patterns
  • Extensive documentation and tutorials for ease of use

Cons of Greykite

  • Steeper learning curve due to more complex API
  • Slower execution time for large datasets
  • Less focus on probabilistic forecasting compared to Orbit

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

Orbit example:

from orbit.models import DLT

model = DLT(
    response_col='y',
    date_col='ds',
    seasonality=[52],
    num_warmup=1000
)
model.fit(df)

Both libraries offer powerful time series forecasting capabilities, but Greykite provides more flexibility in model customization, while Orbit focuses on probabilistic forecasting with a simpler API. Greykite excels in handling complex seasonality, while Orbit is generally faster for smaller datasets. The choice between the two depends on specific project requirements and user expertise.

A statistical library designed to fill the void in Python's time series analysis capabilities, including the equivalent of R's auto.arima function.

Pros of pmdarima

  • Focused specifically on ARIMA modeling, offering more specialized features and optimizations
  • Includes automated model selection and hyperparameter tuning with auto_arima
  • Provides comprehensive documentation and examples for time series forecasting

Cons of pmdarima

  • Limited to ARIMA-based models, less flexible for other time series approaches
  • May require more statistical knowledge from users compared to Orbit's higher-level interface
  • Lacks built-in visualization tools found in Orbit

Code Comparison

pmdarima:

from pmdarima import auto_arima

model = auto_arima(y, seasonal=True, m=12)
forecast = model.predict(n_periods=24)

Orbit:

from orbit.models import DLT

model = DLT(response_col='y', date_col='ds')
model.fit(df)
prediction = model.predict(df)

Both libraries offer concise ways to create and use time series models, but pmdarima focuses on ARIMA-specific implementations while Orbit provides a more general-purpose interface for various time series models.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Join Slack   |   Documentation   |   Blog - Intro   |   Blog - v1.1

Orbit banner


GitHub release (latest SemVer) PyPI Build and Test Documentation Status PyPI - Python Version Downloads Conda Recipe Conda - Platform Conda (channel only) PyPI - License

User Notice

The default page of the repo is on dev branch. To install the dev version, please check the section Installing from Dev Branch. If you are looking for a stable version, please refer to the master branch here.

Disclaimer

This project

  • is stable and being incubated for long-term support. It may contain new experimental code, for which APIs are subject to change.
  • requires cmdstanpy as one of the core dependencies for Bayesian sampling.

Orbit: A Python Package for Bayesian Forecasting

Orbit is a Python package for Bayesian time series forecasting and inference. It provides a familiar and intuitive initialize-fit-predict interface for time series tasks, while utilizing probabilistic programming languages under the hood.

For details, check out our documentation and tutorials:

Currently, it supports concrete implementations for the following models:

  • Exponential Smoothing (ETS)
  • Local Global Trend (LGT)
  • Damped Local Trend (DLT)
  • Kernel Time-based Regression (KTR)

It also supports the following sampling/optimization methods for model estimation/inferences:

  • Markov-Chain Monte Carlo (MCMC) as a full sampling method
  • Maximum a Posteriori (MAP) as a point estimate method
  • Variational Inference (VI) as a hybrid-sampling method on approximate distribution

Installation

Installing Stable Release

Install the library either from PyPi or from the source with pip. Alternatively, you can also install it from Anaconda with conda:

With pip

  1. Installing from PyPI

    $ pip install orbit-ml
    
  2. Install from source

    $ git clone https://github.com/uber/orbit.git
    $ cd orbit
    $ pip install -r requirements.txt
    $ pip install .
    

With conda

The library can be installed from the conda-forge channel using conda.

$ conda install -c conda-forge orbit-ml

Installing from Dev Branch

$ pip install git+https://github.com/uber/orbit.git@dev

Quick Start with Damped-Local-Trend (DLT) Model

FULL Bayesian Prediction

from orbit.utils.dataset import load_iclaims
from orbit.models import DLT
from orbit.diagnostics.plot import plot_predicted_data

# log-transformed data
df = load_iclaims()
# train-test split
test_size = 52
train_df = df[:-test_size]
test_df = df[-test_size:]

dlt = DLT(
  response_col='claims', date_col='week',
  regressor_col=['trend.unemploy', 'trend.filling', 'trend.job'],
  seasonality=52,
)
dlt.fit(df=train_df)

# outcomes data frame
predicted_df = dlt.predict(df=test_df)

plot_predicted_data(
  training_actual_df=train_df, predicted_df=predicted_df,
  date_col=dlt.date_col, actual_col=dlt.response_col,
  test_actual_df=test_df
)

full-pred

Demo

Nowcasting with Regression in DLT:

Open All Collab

Backtest on M3 Data:

Open All Collab

More examples can be found under tutorials and examples.

Contributing

We welcome community contributors to the project. Before you start, please read our code of conduct and check out contributing guidelines first.

Versioning

We document versions and changes in our changelog.

References

Presentations

Check out the ongoing deck for scope and roadmap of the project. An older deck used in the meet-up during July 2021 can also be found here.

Citation

To cite Orbit in publications, refer to the following whitepaper:

Orbit: Probabilistic Forecast with Exponential Smoothing

Bibtex:

@misc{
    ng2020orbit,
    title={Orbit: Probabilistic Forecast with Exponential Smoothing},
    author={Edwin Ng,
        Zhishi Wang,
        Huigang Chen,
        Steve Yang,
        Slawek Smyl},
    year={2020}, eprint={2004.08492}, archivePrefix={arXiv}, primaryClass={stat.CO}
}

Papers

  • Bingham, E., Chen, J. P., Jankowiak, M., Obermeyer, F., Pradhan, N., Karaletsos, T., Singh, R., Szerlip, P., Horsfall, P., and Goodman, N. D. Pyro: Deep universal probabilistic programming. The Journal of Machine Learning Research, 20(1):973–978, 2019.
  • Hoffman, M.D. and Gelman, A. The No-U-Turn sampler: adaptively setting path lengths in Hamiltonian Monte Carlo. J. Mach. Learn. Res., 15(1), pp.1593-1623, 2014.
  • Hyndman, R., Koehler, A. B., Ord, J. K., and Snyder, R. D. Forecasting with exponential smoothing: the state space approach. Springer Science & Business Media, 2008.
  • Smyl, S. Zhang, Q. Fitting and Extending Exponential Smoothing Models with Stan. International Symposium on Forecasting, 2015.

Related projects