Skip to main content

TimeMurmur

Requires the forecast period is the same for all time series.

Quickstart

pip install TimeMurmur

Get example dataset and ensure the date column is Datetime:

from TimeMurmur.utils.utility_functions import get_data
train_df = get_data()
train_df['Datetime'] = pd.to_datetime(train_df['Datetime'])

This dataset is a subset of the weekly data from M4, it includes the required ID, Datetime, and History columns.

The most basic model you can fit is:

murmur = Murmur(floor=0)
fitted = murmur.fit(train_df,
                    target_column='History',
                    id_column='ID',
                    date_column='Datetime',
                    freq='W')
predicted = murmur.predict(20)

These parameters are required, the freq is 'W' for Weekly following standard frequency nomenclature. You can take a look with the helper function:

for i in range(3):
    murmur.plot(fitted, predicted=predicted, murmur_id=i)

Adding AR Lags

In order to do recursive forecasting utilizing past values, just pass a list of lags you want to the ar parameter:

murmur = Murmur(floor=0)
fitted = murmur.fit(train_df,
                    target_column='History',
                    id_column='ID',
                    date_column='Datetime',
                    freq='W',
                    n_basis=[10],
                    ar=[1,2,3,4])
predicted = murmur.predict(20)

Here we use a linear basis function with 4 ar lags passed as a list.

Adding Seasonality

Seasonality works similar to the ar lags. We can pass multiple seasonal periods in a list if we have multiple seasonalities to account for.

murmur = Murmur(floor=0)
fitted = murmur.fit(train_df,
                    target_column='History',
                    id_column='ID',
                    date_column='Datetime',
                    freq='W',
                    n_basis=[10],
                    ar=[1,2,3,4],
                    seasonal_period=[4,52])
predicted = murmur.predict(20)

LightGBM Parameters

You can pass a few of the most influential LightGBM parameters to fit such as num_iterations and num_leaves:

murmur = Murmur(floor=0)
fitted = murmur.fit(train_df,
                    target_column='History',
                    id_column='ID',
                    date_column='Datetime',
                    freq='W',
                    n_basis=[10],
                    ar=[1,2,3,4],
                    seasonal_period=[4,52],
                    num_iterations=100,
                    learning_rate=.1,
                    num_leaves=31)
predicted = murmur.predict(20)

Fitting with category exogenous.

This is a 'ID' axis variable since it never changes across time only across IDs. Since it is a string we pass it to 'categorical_columns' as well.

murmur = Murmur(floor=0)
fitted = murmur.fit(train_df,
                    target_column='History',
                    id_column='ID',
                    date_column='Datetime',
                    freq='W',
                    n_basis=[10],
                    ar=[1,2,3,4],
                    seasonal_period=[4,52],
                    num_iterations=100,
                    learning_rate=.1,
                    num_leaves=31,
                    categorical_columns=['category'],
                    id_feature_columns=['category'])
predicted = murmur.predict(20)

Fitting Quantiles

To fit quantiles pass quantile for objective and the desired quantile percentage to alpha.

murmur = Murmur(floor=0)
fitted = murmur.fit(train_df,
                    target_column='History',
                    id_column='ID',
                    date_column='Datetime',
                    freq='W',
                    n_basis=[10],
                    ar=[1,2,3,4],
                    seasonal_period=[4,52],
                    num_iterations=100,
                    learning_rate=.1,
                    num_leaves=31,
                    objective='quantile',
                    alpha=.9)
predicted = murmur.predict(20)

Explanations with Shapley

#get shapley values of predictions
predicted_shap_vals = murmur.explain_predictions(predicted)
fitted_shap_vals = murmur.explain_fitted(fitted)
#plot using shapley values
murmur.plot_explanations(fitted_shap_vals=fitted_shap_vals,
                         predicted_shap_vals=predicted_shap_vals,
                         murmur_id=0)

Metadata

Release files for TimeMurmur 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for TimeMurmur 0.1.3
File Interpreter ABI Platform
TimeMurmur-0.1.3-py3-none-any.whl Python 3 none any Details

Release files / TimeMurmur-0.1.3-py3-none-any.whl

Download URL TimeMurmur-0.1.3-py3-none-any.whl
Size 27.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b4ab4872f2c06469d27acd9b58248e341da4caad04ccd25a2594f0e909773eb
BLAKE2b-256 checksum
How to use checksums
585e19d32e5b2a777660e01b4228915e2b0abb79b733cde9d413f6b2846c931a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.15

Release history Release notifications | RSS feed

This release

0.1.3 This release

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page