You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+156-74
Original file line number
Diff line number
Diff line change
@@ -16,21 +16,21 @@
16
16
</div>
17
17
18
18
<divstyle="text-align: center;">
19
-
<h1>Mambular: Tabular Deep Learning (with Mamba)</h1>
19
+
<h1>Mambular: Tabular Deep Learning Made Simple</h1>
20
20
</div>
21
21
22
-
Mambular is a Python library for tabular deep learning. It includes models that leverage the Mamba (State Space Model) architecture, as well as other popular models like TabTransformer, FTTransformer, and tabular ResNets. Check out our paper `Mambular: A Sequential Model for Tabular Deep Learning`, available [here](https://arxiv.org/abs/2408.06291).
22
+
Mambular is a Python library for tabular deep learning. It includes models that leverage the Mamba (State Space Model) architecture, as well as other popular models like TabTransformer, FTTransformer, TabM and tabular ResNets. Check out our paper `Mambular: A Sequential Model for Tabular Deep Learning`, available [here](https://arxiv.org/abs/2408.06291). Also check out our paper introducing [TabulaRNN](https://arxiv.org/pdf/2411.17207) and analyzing the efficiency of NLP inspired tabular models.
23
23
24
24
<h3> Table of Contents </h3>
25
25
26
26
-[🏃 Quickstart](#-quickstart)
27
27
-[📖 Introduction](#-introduction)
28
28
-[🤖 Models](#-models)
29
-
-[🏆 Results](#-results)
30
29
-[📚 Documentation](#-documentation)
31
30
-[🛠️ Installation](#️-installation)
32
31
-[🚀 Usage](#-usage)
33
32
-[💻 Implement Your Own Model](#-implement-your-own-model)
33
+
-[Custom Training](#custom-training)
34
34
-[🏷️ Citation](#️-citation)
35
35
-[License](#license)
36
36
@@ -55,75 +55,24 @@ Mambular is a Python package that brings the power of advanced deep learning arc
|`Mambular`| A sequential model using Mamba blocks [Gu and Dao](https://arxiv.org/pdf/2312.00752) specifically designed for various tabular data tasks. |
58
+
|`Mambular`| A sequential model using Mamba blocks specifically designed for various tabular data tasks introduced [here](https://arxiv.org/abs/2408.06291). |
59
+
|`TabM`| Batch Ensembling for a MLP as introduced by [Gorishniy et al.](https://arxiv.org/abs/2410.24210)|
60
+
|`NODE`| Neural Oblivious Decision Ensembles as introduced by [Popov et al.](https://arxiv.org/abs/1909.06312)|
59
61
|`FTTransformer`| A model leveraging transformer encoders, as introduced by [Gorishniy et al.](https://arxiv.org/abs/2106.11959), for tabular data. |
60
62
|`MLP`| A classical Multi-Layer Perceptron (MLP) model for handling tabular data tasks. |
61
63
|`ResNet`| An adaptation of the ResNet architecture for tabular data applications. |
62
64
|`TabTransformer`| A transformer-based model for tabular data introduced by [Huang et al.](https://arxiv.org/abs/2012.06678), enhancing feature learning capabilities. |
63
65
|`MambaTab`| A tabular model using a Mamba-Block on a joint input representation described [here](https://arxiv.org/abs/2401.08867) . Not a sequential model. |
64
-
|`TabulaRNN`| A Recurrent Neural Network for Tabular data. Not yet included in the benchmarks |
66
+
|`TabulaRNN`| A Recurrent Neural Network for Tabular data, introduced [here](https://arxiv.org/pdf/2411.17207). |
67
+
|`MambAttention`| A combination between Mamba and Transformers, also introduced [here](https://arxiv.org/pdf/2411.17207). |
68
+
|`NDTF`| A neural decision forest using soft decision trees. See [Kontschieder et al.](https://openaccess.thecvf.com/content_iccv_2015/html/Kontschieder_Deep_Neural_Decision_ICCV_2015_paper.html) for inspiration. |
69
+
65
70
66
71
67
72
All models are available for `regression`, `classification` and distributional regression, denoted by `LSS`.
68
73
Hence, they are available as e.g. `MambularRegressor`, `MambularClassifier` or `MambularLSS`
69
74
70
75
71
-
# 🏆 Results
72
-
Detailed results for the available methods can be found [here](https://arxiv.org/abs/2408.06291).
73
-
Note, that these are achieved results with default hyperparameter and for our splits. Performing hyperparameter optimization could improve the performance of all models.
74
-
75
-
The average rank table over all models and all datasets is given here:
@@ -143,12 +105,18 @@ Mambular simplifies data preprocessing with a range of tools designed for easy t
143
105
144
106
<h3> Data Type Detection and Transformation </h3>
145
107
146
-
-**Ordinal & One-Hot Encoding**: Automatically transforms categorical data into numerical formats.
147
-
-**Binning**: Discretizes numerical features; can use decision trees for optimal binning.
148
-
-**Normalization & Standardization**: Scales numerical data appropriately.
149
-
-**Periodic Linear Encoding (PLE)**: Encodes periodicity in numerical data.
150
-
-**Quantile & Spline Transformations**: Applies advanced transformations to handle nonlinearity and distributional shifts.
151
-
-**Polynomial Features**: Generates polynomial and interaction terms to capture complex relationships.
108
+
-**Ordinal & One-Hot Encoding**: Automatically transforms categorical data into numerical formats using continuous ordinal encoding or one-hot encoding. Includes options for transforming outputs to `float` for compatibility with downstream models.
109
+
-**Binning**: Discretizes numerical features into bins, with support for both fixed binning strategies and optimal binning derived from decision tree models.
110
+
-**MinMax**: Scales numerical data to a specific range, such as [-1, 1], using Min-Max scaling or similar techniques.
111
+
-**Standardization**: Centers and scales numerical features to have a mean of zero and unit variance for better compatibility with certain models.
112
+
-**Quantile Transformations**: Normalizes numerical data to follow a uniform or normal distribution, handling distributional shifts effectively.
113
+
-**Spline Transformations**: Captures nonlinearity in numerical features using spline-based transformations, ideal for complex relationships.
114
+
-**Piecewise Linear Encodings (PLE)**: Captures complex numerical patterns by applying piecewise linear encoding, suitable for data with periodic or nonlinear structures.
115
+
-**Polynomial Features**: Automatically generates polynomial and interaction terms for numerical features, enhancing the ability to capture higher-order relationships.
116
+
-**Box-Cox & Yeo-Johnson Transformations**: Performs power transformations to stabilize variance and normalize distributions.
117
+
-**Custom Binning**: Enables user-defined bin edges for precise discretization of numerical data.
118
+
119
+
152
120
153
121
154
122
<h2> Fit a Model </h2>
@@ -159,9 +127,10 @@ from mambular.models import MambularClassifier
159
127
# Initialize and fit your model
160
128
model = MambularClassifier(
161
129
d_model=64,
162
-
n_layers=8,
130
+
n_layers=4,
163
131
numerical_preprocessing="ple",
164
-
n_bins=50
132
+
n_bins=50,
133
+
d_conv=8
165
134
)
166
135
167
136
# X can be a dataframe or something that can be easily transformed into a pd.DataFrame as a np.array
@@ -177,6 +146,59 @@ preds = model.predict(X)
177
146
preds = model.predict_proba(X)
178
147
```
179
148
149
+
<h3> Hyperparameter Optimization</h3>
150
+
Since all of the models are sklearn base estimators, you can use the built-in hyperparameter optimizatino from sklearn.
151
+
152
+
```python
153
+
from sklearn.model_selection import RandomizedSearchCV
Note, that using this, you can also optimize the preprocessing. Just use the prefix ``prepro__`` when specifying the preprocessor arguments you want to optimize:
Since we have early stopping integrated and return the best model with respect to the validation loss, setting max_epochs to a large number is sensible.
192
+
193
+
194
+
Or use the built-in bayesian hpo simply by running:
195
+
196
+
```python
197
+
best_params = model.optimize_hparams(X, y)
198
+
```
199
+
200
+
This automatically sets the search space based on the default config from ``mambular.configs``. See the documentation for all params with regard to ``optimize_hparams()``. However, the preprocessor arguments are fixed and cannot be optimized here.
201
+
180
202
181
203
<h2> ⚖️ Distributional Regression with MambularLSS </h2>
182
204
@@ -260,6 +282,7 @@ Here's how you can implement a custom model with Mambular:
260
282
261
283
```python
262
284
from mambular.base_models import BaseModel
285
+
from mambular.utils.get_feature_dimensions import get_feature_dimensions
263
286
import torch
264
287
import torch.nn
265
288
@@ -275,11 +298,7 @@ Here's how you can implement a custom model with Mambular:
@@ -311,6 +330,59 @@ Here's how you can implement a custom model with Mambular:
311
330
regressor.fit(X_train, y_train, max_epochs=50)
312
331
```
313
332
333
+
# Custom Training
334
+
If you prefer to setup custom training, preprocessing and evaluation, you can simply use the `mambular.base_models`.
335
+
Just be careful that all basemodels expect lists of features as inputs. More precisely as list for numerical features and a list for categorical features. A custom training loop, with random data could look like this.
336
+
337
+
```python
338
+
import torch
339
+
import torch.nn as nn
340
+
import torch.optim as optim
341
+
from mambular.base_models import Mambular
342
+
from mambular.configs import DefaultMambularConfig
0 commit comments