Skip to main content

Seánce v0.0.5

A simple wrapper around Nixtla's MLForecast aimed at streamlining plug-and-play forecasting.

A general pattern is to optimize then forecast such as:

from mlforecast.utils import generate_daily_series
series = generate_daily_series(
    n_series=20,
    max_length=100,
    min_length=50,
    with_trend=True
)


from Seance.Optimizer import Optimize
opt = Optimize(series,
            target_column='y',
            date_column='ds',
            id_column='unique_id',
            freq='D',
            seasonal_period=7,
            test_size=10,
            # ar_lags=[list(range(1, 8))], #by default this will be done based on seasonal period
            metric='smape',
            n_trials=100)
#returns an optuna study obj
best_params, study = opt.fit(seed=1)

optuna plotting

import optuna
optuna.visualization.matplotlib.plot_param_importances(study)

alt text Here we can see the most important parameter is (unsurprisingly) the number of lags. Followd by decay which controls the 'forgetfulness' of the basis functions.

optuna.visualization.matplotlib.plot_optimization_history(study)

alt text

passing off best params for forecasts

from Seance.Forecaster import Forecaster
seance = Forecaster()
output = seance.fit(series,
                    target_column='y',
                    date_column='ds',
                    id_column='unique_id',
                    freq='D',
                    **best_params)
predicted = seance.predict(24)

quick plot of the forecasts

import matplotlib.pyplot as plt
plot_ser = np.append(series[series['unique_id'] == 'id_00']['y'].values,
                     predicted[predicted['unique_id'] == 'id_00']['LGBMRegressor'].values)
plt.plot(plot_ser)
plt.vlines(x=len(plot_ser) - 24, ymin=0, ymax=max(plot_ser), linestyle='dashed', color='red')
plt.show()

alt text

Metadata

Release files for Seance 0.1.4

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 Seance 0.1.4
File Interpreter ABI Platform
Seance-0.1.4-py3-none-any.whl Python 3 none any Details

Release files / Seance-0.1.4-py3-none-any.whl

Download URL Seance-0.1.4-py3-none-any.whl
Size 16.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
02b5cb0d9dc08c5b7684a278e27510ee99004a5ee1b007b3faa2e6ae31f51b86
BLAKE2b-256 checksum
How to use checksums
a0c658b3b302675f76c1eeae6c379e97ac859ea8e7070e83c5e4cd5526e71fcc
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.4 This release

1 release file

0.1.3

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