Skip to content

Commit 06fd8fb

Browse files
authored
Merge pull request #290 from OpenTabular/develop
Develop
2 parents 3c21591 + 3899c90 commit 06fd8fb

File tree

133 files changed

+3625
-3625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+3625
-3625
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ If applicable, add screenshots to help explain your problem.
2222
**Desktop (please complete the following information):**
2323
- OS: [e.g. Ubuntu]
2424
- Python version [e.g. 3.8]
25-
- DeepTabular Version [e.g. 1.6.0]
25+
- deeptab Version [e.g. 1.6.0]
2626

2727
**Additional context**
2828
Add any other context about the problem here.

README.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
<img src="./docs/images/logo/mamba_tabular.jpg" width="400"/>
33

44

5-
[![PyPI](https://img.shields.io/pypi/v/deeptabular)](https://pypi.org/project/deeptabular)
6-
![PyPI - Downloads](https://img.shields.io/pypi/dm/deeptabular)
7-
[![docs build](https://readthedocs.org/projects/deeptabular/badge/?version=latest)](https://deeptabular.readthedocs.io/en/latest/?badge=latest)
8-
[![docs](https://img.shields.io/badge/docs-latest-blue)](https://deeptabular.readthedocs.io/en/latest/)
9-
[![open issues](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/OpenTabular/DeepTabular/issues)
5+
[![PyPI](https://img.shields.io/pypi/v/deeptab)](https://pypi.org/project/deeptab)
6+
![PyPI - Downloads](https://img.shields.io/pypi/dm/deeptab)
7+
[![docs build](https://readthedocs.org/projects/deeptab/badge/?version=latest)](https://deeptab.readthedocs.io/en/latest/?badge=latest)
8+
[![docs](https://img.shields.io/badge/docs-latest-blue)](https://deeptab.readthedocs.io/en/latest/)
9+
[![open issues](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/OpenTabular/deeptab/issues)
1010

1111

12-
[📘Documentation](https://deeptabular.readthedocs.io/en/latest/index.html) |
13-
[🛠️Installation](https://deeptabular.readthedocs.io/en/latest/installation.html) |
14-
[Models](https://deeptabular.readthedocs.io/en/latest/api/models/index.html) |
15-
[🤔Report Issues](https://github.com/OpenTabular/DeepTabular/issues)
12+
[📘Documentation](https://deeptab.readthedocs.io/en/latest/index.html) |
13+
[🛠️Installation](https://deeptab.readthedocs.io/en/latest/installation.html) |
14+
[Models](https://deeptab.readthedocs.io/en/latest/api/models/index.html) |
15+
[🤔Report Issues](https://github.com/OpenTabular/deeptab/issues)
1616
</div>
1717

1818
<div style="text-align: center;">
19-
<h1>DeepTabular: Tabular Deep Learning Made Simple</h1>
19+
<h1>deeptab: Tabular Deep Learning Made Simple</h1>
2020
</div>
2121

22-
DeepTabular 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.
22+
deeptab 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.
2323

2424
<h3>⚡ What's New ⚡</h3>
2525
<ul>
@@ -48,10 +48,10 @@ DeepTabular is a Python library for tabular deep learning. It includes models th
4848

4949

5050
# 🏃 Quickstart
51-
Similar to any sklearn model, DeepTabular models can be fit as easy as this:
51+
Similar to any sklearn model, deeptab models can be fit as easy as this:
5252

5353
```python
54-
from deeptabular.models import MambularClassifier
54+
from deeptab.models import MambularClassifier
5555
# Initialize and fit your model
5656
model = MambularClassifier()
5757

@@ -60,7 +60,7 @@ model.fit(X, y, max_epochs=150, lr=1e-04)
6060
```
6161

6262
# 📖 Introduction
63-
DeepTabular is a Python package that brings the power of advanced deep learning architectures to tabular data, offering a suite of models for regression, classification, and distributional regression tasks. Designed with ease of use in mind, DeepTabular 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 DeepTabular models just as you would with any traditional scikit-learn model, but with the added performance and flexibility of deep learning.
63+
deeptab is a Python package that brings the power of advanced deep learning architectures to tabular data, offering a suite of models for regression, classification, and distributional regression tasks. Designed with ease of use in mind, deeptab 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 deeptab models just as you would with any traditional scikit-learn model, but with the added performance and flexibility of deep learning.
6464

6565

6666
# 🤖 Models
@@ -94,13 +94,13 @@ Hence, they are available as e.g. `MambularRegressor`, `MambularClassifier` or `
9494

9595
# 📚 Documentation
9696

97-
You can find the DeepTabular API documentation [here](https://deeptabular.readthedocs.io/en/latest/).
97+
You can find the deeptab API documentation [here](https://deeptab.readthedocs.io/en/latest/).
9898

9999
# 🛠️ Installation
100100

101-
Install DeepTabular using pip:
101+
Install deeptab using pip:
102102
```sh
103-
pip install deeptabular
103+
pip install deeptab
104104
```
105105

106106
If you want to use the original mamba and mamba2 implementations, additionally install mamba-ssm via:
@@ -120,7 +120,7 @@ pip install mamba-ssm
120120

121121
<h2> Preprocessing </h2>
122122

123-
DeepTabular uses pretab preprocessing: https://github.com/OpenTabular/PreTab
123+
deeptab uses pretab preprocessing: https://github.com/OpenTabular/PreTab
124124

125125
Hence, datatypes etc. are detected automatically and all preprocessing methods from pretab as well as from Sklearn.preprocessing are available.
126126
Additionally, you can specify that each feature is preprocessed differently, according to your requirements, by setting the `feature_preprocessing={}`argument during model initialization.
@@ -144,10 +144,10 @@ For an overview over all available methods: [pretab](https://github.com/OpenTabu
144144

145145

146146
<h2> Fit a Model </h2>
147-
Fitting a model in deeptabular is as simple as it gets. All models in deeptabular are sklearn BaseEstimators. Thus the `.fit` method is implemented for all of them. Additionally, this allows for using all other sklearn inherent methods such as their built in hyperparameter optimization tools.
147+
Fitting a model in deeptab is as simple as it gets. All models in deeptab are sklearn BaseEstimators. Thus the `.fit` method is implemented for all of them. Additionally, this allows for using all other sklearn inherent methods such as their built in hyperparameter optimization tools.
148148

149149
```python
150-
from deeptabular.models import MambularClassifier
150+
from deeptab.models import MambularClassifier
151151
# Initialize and fit your model
152152
model = MambularClassifier(
153153
d_model=64,
@@ -243,12 +243,12 @@ Or use the built-in bayesian hpo simply by running:
243243
best_params = model.optimize_hparams(X, y)
244244
```
245245

246-
This automatically sets the search space based on the default config from ``deeptabular.configs``. See the documentation for all params with regard to ``optimize_hparams()``. However, the preprocessor arguments are fixed and cannot be optimized here.
246+
This automatically sets the search space based on the default config from ``deeptab.configs``. See the documentation for all params with regard to ``optimize_hparams()``. However, the preprocessor arguments are fixed and cannot be optimized here.
247247

248248

249249
<h2> ⚖️ Distributional Regression with MambularLSS </h2>
250250

251-
MambularLSS allows you to model the full distribution of a response variable, not just its mean. This is crucial when understanding variability, skewness, or kurtosis is important. All DeepTabular models are available as distributional models.
251+
MambularLSS allows you to model the full distribution of a response variable, not just its mean. This is crucial when understanding variability, skewness, or kurtosis is important. All deeptab models are available as distributional models.
252252

253253
<h3> Key Features of MambularLSS: </h3>
254254

@@ -277,10 +277,10 @@ These distribution classes make MambularLSS versatile in modeling various data t
277277

278278
<h3> Getting Started with MambularLSS: </h3>
279279

280-
To integrate distributional regression into your workflow with `MambularLSS`, start by initializing the model with your desired configuration, similar to other DeepTabular models:
280+
To integrate distributional regression into your workflow with `MambularLSS`, start by initializing the model with your desired configuration, similar to other deeptab models:
281281

282282
```python
283-
from deeptabular.models import MambularLSS
283+
from deeptab.models import MambularLSS
284284

285285
# Initialize the MambularLSS model
286286
model = MambularLSS(
@@ -305,18 +305,18 @@ model.fit(
305305

306306
# 💻 Implement Your Own Model
307307

308-
DeepTabular allows users to easily integrate their custom models into the existing logic. This process is designed to be straightforward, making it simple to create a PyTorch model and define its forward pass. Instead of inheriting from `nn.Module`, you inherit from DeepTabular's `BaseModel`. Each DeepTabular model takes three main arguments: the number of classes (e.g., 1 for regression or 2 for binary classification), `cat_feature_info`, and `num_feature_info` for categorical and numerical feature information, respectively. Additionally, you can provide a config argument, which can either be a custom configuration or one of the provided default configs.
308+
deeptab allows users to easily integrate their custom models into the existing logic. This process is designed to be straightforward, making it simple to create a PyTorch model and define its forward pass. Instead of inheriting from `nn.Module`, you inherit from deeptab's `BaseModel`. Each deeptab model takes three main arguments: the number of classes (e.g., 1 for regression or 2 for binary classification), `cat_feature_info`, and `num_feature_info` for categorical and numerical feature information, respectively. Additionally, you can provide a config argument, which can either be a custom configuration or one of the provided default configs.
309309

310-
One of the key advantages of using DeepTabular is that the inputs to the forward passes are lists of tensors. While this might be unconventional, it is highly beneficial for models that treat different data types differently. For example, the TabTransformer model leverages this feature to handle categorical and numerical data separately, applying different transformations and processing steps to each type of data.
310+
One of the key advantages of using deeptab is that the inputs to the forward passes are lists of tensors. While this might be unconventional, it is highly beneficial for models that treat different data types differently. For example, the TabTransformer model leverages this feature to handle categorical and numerical data separately, applying different transformations and processing steps to each type of data.
311311

312-
Here's how you can implement a custom model with DeepTabular:
312+
Here's how you can implement a custom model with deeptab:
313313

314314
1. **First, define your config:**
315315
The configuration class allows you to specify hyperparameters and other settings for your model. This can be done using a simple dataclass.
316316

317317
```python
318318
from dataclasses import dataclass
319-
from deeptabular.configs import BaseConfig
319+
from deeptab.configs import BaseConfig
320320

321321
@dataclass
322322
class MyConfig(BaseConfig):
@@ -332,8 +332,8 @@ Here's how you can implement a custom model with DeepTabular:
332332
Define your custom model just as you would for an `nn.Module`. The main difference is that you will inherit from `BaseModel` and use the provided feature information to construct your layers. To integrate your model into the existing API, you only need to define the architecture and the forward pass.
333333

334334
```python
335-
from deeptabular.base_models.utils import BaseModel
336-
from deeptabular.utils.get_feature_dimensions import get_feature_dimensions
335+
from deeptab.base_models.utils import BaseModel
336+
from deeptab.utils.get_feature_dimensions import get_feature_dimensions
337337
import torch
338338
import torch.nn
339339

@@ -372,19 +372,19 @@ Here's how you can implement a custom model with DeepTabular:
372372
return output
373373
```
374374

375-
3. **Leverage the DeepTabular API:**
376-
You can build a regression, classification, or distributional regression model that can leverage all of DeepTabular's built-in methods by using the following:
375+
3. **Leverage the deeptab API:**
376+
You can build a regression, classification, or distributional regression model that can leverage all of deeptab's built-in methods by using the following:
377377

378378
```python
379-
from deeptabular.models.utils import SklearnBaseRegressor
379+
from deeptab.models.utils import SklearnBaseRegressor
380380

381381
class MyRegressor(SklearnBaseRegressor):
382382
def __init__(self, **kwargs):
383383
super().__init__(model=MyCustomModel, config=MyConfig, **kwargs)
384384
```
385385

386386
4. **Train and evaluate your model:**
387-
You can now fit, evaluate, and predict with your custom model just like with any other DeepTabular model. For classification or distributional regression, inherit from `SklearnBaseClassifier` or `SklearnBaseLSS` respectively.
387+
You can now fit, evaluate, and predict with your custom model just like with any other deeptab model. For classification or distributional regression, inherit from `SklearnBaseClassifier` or `SklearnBaseLSS` respectively.
388388

389389
```python
390390
regressor = MyRegressor(numerical_preprocessing="ple")
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import torch
22
import torch.nn as nn
33
import torch.nn.functional as F
4-
from deeptabular.arch_utils.layer_utils.sparsemax import sparsemax, sparsemoid
4+
from deeptab.arch_utils.layer_utils.sparsemax import sparsemax, sparsemoid
55
from .data_aware_initialization import ModuleWithInit
66
from .numpy_utils import check_numpy
77
import numpy as np
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
1-
from .layer_utils.normalization_layers import (
2-
BatchNorm,
3-
GroupNorm,
4-
InstanceNorm,
5-
LayerNorm,
6-
LearnableLayerScaling,
7-
RMSNorm,
8-
)
9-
10-
11-
def get_normalization_layer(config):
12-
"""Function to return the appropriate normalization layer based on the configuration.
13-
14-
Parameters:
15-
-----------
16-
config : DefaultMambularConfig
17-
Configuration object containing the parameters for the model including normalization.
18-
19-
Returns:
20-
--------
21-
nn.Module:
22-
The normalization layer as per the config.
23-
24-
Raises:
25-
-------
26-
ValueError:
27-
If an unsupported normalization layer is specified in the config.
28-
"""
29-
30-
norm_layer = getattr(config, "norm", None)
31-
d_model = getattr(config, "d_model", 128)
32-
layer_norm_eps = getattr(config, "layer_norm_eps", 1e-05)
33-
34-
if norm_layer == "RMSNorm":
35-
return RMSNorm(d_model, eps=layer_norm_eps)
36-
elif norm_layer == "LayerNorm":
37-
return LayerNorm(d_model, eps=layer_norm_eps)
38-
elif norm_layer == "BatchNorm":
39-
return BatchNorm(d_model, eps=layer_norm_eps)
40-
elif norm_layer == "InstanceNorm":
41-
return InstanceNorm(d_model, eps=layer_norm_eps)
42-
elif norm_layer == "GroupNorm":
43-
return GroupNorm(1, d_model, eps=layer_norm_eps)
44-
elif norm_layer == "LearnableLayerScaling":
45-
return LearnableLayerScaling(d_model)
46-
elif norm_layer is None:
47-
return None
48-
else:
49-
raise ValueError(f"Unsupported normalization layer: {norm_layer}")
1+
from .layer_utils.normalization_layers import (
2+
BatchNorm,
3+
GroupNorm,
4+
InstanceNorm,
5+
LayerNorm,
6+
LearnableLayerScaling,
7+
RMSNorm,
8+
)
9+
10+
11+
def get_normalization_layer(config):
12+
"""Function to return the appropriate normalization layer based on the configuration.
13+
14+
Parameters:
15+
-----------
16+
config : DefaultMambularConfig
17+
Configuration object containing the parameters for the model including normalization.
18+
19+
Returns:
20+
--------
21+
nn.Module:
22+
The normalization layer as per the config.
23+
24+
Raises:
25+
-------
26+
ValueError:
27+
If an unsupported normalization layer is specified in the config.
28+
"""
29+
30+
norm_layer = getattr(config, "norm", None)
31+
d_model = getattr(config, "d_model", 128)
32+
layer_norm_eps = getattr(config, "layer_norm_eps", 1e-05)
33+
34+
if norm_layer == "RMSNorm":
35+
return RMSNorm(d_model, eps=layer_norm_eps)
36+
elif norm_layer == "LayerNorm":
37+
return LayerNorm(d_model, eps=layer_norm_eps)
38+
elif norm_layer == "BatchNorm":
39+
return BatchNorm(d_model, eps=layer_norm_eps)
40+
elif norm_layer == "InstanceNorm":
41+
return InstanceNorm(d_model, eps=layer_norm_eps)
42+
elif norm_layer == "GroupNorm":
43+
return GroupNorm(1, d_model, eps=layer_norm_eps)
44+
elif norm_layer == "LearnableLayerScaling":
45+
return LearnableLayerScaling(d_model)
46+
elif norm_layer is None:
47+
return None
48+
else:
49+
raise ValueError(f"Unsupported normalization layer: {norm_layer}")
File renamed without changes.

0 commit comments

Comments
 (0)