wzhwzhwzh0921 / S-D-Mamba

Code for "Is Mamba Effective for Time Series Forecasting?"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use Mamba for forecasting

IsmailKhazi opened this issue · comments

Hello can you provide a Python Notebook for "How to do forecasting using Mamba?"

How to use Mamba to forecast and compare with LSTM, RNN also.

You can read Mamba's paper to learn the principles of Mamba Block. In fact, the input and output of Mamba Block are the same as those of classic RNN models such as LSTM and GRU. The input is the original tensor of the BLD shape, and the output is the hidden tensor (BLD Shape) corresponding to each position.

An little example for forecasting in a notebook would be great @wzhwzhwzh0921

The data preproccesing for excatly this model i cant help. I just build an Prototype of the iTransformer model last week for TSA.
For encode categorial data just encode it with numbers. If i get you problem right that would be something like bus:1 train:2 .... and after encoding you can normalize the data with sin/cos.

You can try Mambular (Mamba for Tabular data) new Python package ready to use:

https://github.com/basf/mamba-tabular

Yes, it is Mamba based. Take a look at the description and docs:
https://mambular.readthedocs.io/

Mambular is a Python package that brings the power of Mamba architectures to tabular data, offering a suite of deep learning models for regression, classification, and distributional regression tasks. Designed with ease of use in mind, Mambular models adhere to scikit-learn's BaseEstimator interface, making them highly compatible with the familiar scikit-learn ecosystem. This means you can fit, predict, and evaluate using Mambular models just as you would with any traditional scikit-learn model, but with the added performance and flexibility of deep learning.

You can use the regression. In the train_test_split use shuffle=False to avoid leaking future samples in the training.
Please, show how your data is structured. The description you sent above is confused because mixed columns.
You can use print screen and paste here.

Name Description Data Type Example
service_date Date on which the trip took place. Service dates run from
around 2:00AM - 1:59:59AM Date 2019-12-31
route_id Route Id String 01

Is it also appliable for probalistic output to do multilabel classification? @ericleonardo

Is it also appliable for probalistic output to do multilabel classification? @ericleonardo

You can try the Classification with multiclass output. In the example, it is used 4 classes:
https://mambular.readthedocs.io/en/latest/examples/classification.html

Generate target variable:
y = np.dot(X, coefficients) + np.random.randn(n_samples)
Convert y to multiclass by categorizing into quartiles
y = pd.qcut(y, 4, labels=False)

@ericleonardo Hey, thanks for the fast reply.
I think you got me wrong there, i need an probalistic output for each class for a mutlilabel prediction. That means each input can be more than just one class.
Example
Input Class1 Class2 Class3
19.6.24 1 0 1

@ericleonardo Hey, thanks for the fast reply. I think you got me wrong there, i need an probalistic output for each class for a mutlilabel prediction. That means each input can be more than just one class. Example Input Class1 Class2 Class3 19.6.24 1 0 1

I don't know if it will output class probabilities. You can ask the author:
https://github.com/basf/mamba-tabular