How to Get Started with the Orbit Python Package for Bayesian Forecasting

Jun 3, 2022 | Data Science

Welcome to the world of Bayesian time series forecasting! Today, we’ll explore how you can utilize the powerful Orbit Python package to perform Bayesian forecasting and inference effectively. This guide will walk you through the installation steps, a quick start with a model, and some troubleshooting tips to ensure a smooth experience.

What is Orbit?

Orbit is a Python package designed for Bayesian time series forecasting and inference. It uses an intuitive initialize-fit-predict interface, making it user-friendly for both beginners and experts. Underneath, it cleverly employs probabilistic programming languages, making statistical modeling approachable while maintaining depth and complexity. Think of Orbit as your handy toolkit that helps you predict future events based on past data – like having a weather app that factors in clouds, humidity, and temperatures to give accurate forecasts.

Installation

To get started using Orbit, the first step is installing it. You can choose to install the stable release or the development version. Here’s how to do both:

Installing Stable Release

  • With pip:
    $ pip install orbit-ml
    $ git clone https://github.com/uber/orbit.git
    $ cd orbit
    $ pip install -r requirements.txt
    $ pip install .
  • With 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

Once you have installed Orbit, you’ll want to try out a model. Below are the steps to get started with the DLT model:

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

# Load log-transformed data
df = load_iclaims()

# Train-test split
test_size = 52
train_df = df[:-test_size]
test_df = df[-test_size:]

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

# Predict outcomes and plot
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
)

In this example, you can think of loading your dataset and fitting the model like preparing for a marathon. You need to gather the right gear (data) and warm up (fit the model) before you can actually start running (predicting outcomes)!

Troubleshooting

If you encounter issues while running Orbit, here are some troubleshooting ideas:

  • Ensure you have all dependencies installed, especially cmdstanpy, which is essential for Bayesian sampling.
  • Check that you are using a compatible version of Python and other packages as listed in the documentation.
  • If installation issues persist, consider cloning the repository and installing from the source to avoid any package conflicts.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

With Orbit, you can leverage the power of Bayesian forecasting for various applications. This package allows you to explore time-series data with a flexible and intuitive modeling approach. So lace up your shoes and get ready to predict like never before! At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox