A standard framework for using Deep Learning for tabular data
Project description
PyTorch Tabular aims to make Deep Learning with Tabular data easy and accessible to real-world cases and research alike. The core principles behind the design of the library are:
- Low Resistance Usability
- Easy Customization
- Scalable and Easier to Deploy
It has been built on the shoulders of giants like PyTorch(obviously), and PyTorch Lightning.
Table of Contents
Installation
Although the installation includes PyTorch, the best and recommended way is to first install PyTorch from here, picking up the right CUDA version for your machine.
Once, you have got Pytorch installed, just use:
pip install -U pytorch_tabular[extra]
to install the complete library with extra dependencies (Weights&Biases & Plotly).
And :
pip install -U pytorch_tabular
for the bare essentials.
The sources for pytorch_tabular can be downloaded from the Github repo
_.
You can either clone the public repository:
git clone git://github.com/manujosephv/pytorch_tabular
Once you have a copy of the source, you can install it with:
cd pytorch_tabular && pip install .[extra]
Documentation
For complete Documentation with tutorials visit ReadTheDocs
Available Models
- FeedForward Network with Category Embedding is a simple FF network, but with an Embedding layers for the categorical columns.
- Neural Oblivious Decision Ensembles for Deep Learning on Tabular Data is a model presented in ICLR 2020 and according to the authors have beaten well-tuned Gradient Boosting models on many datasets.
- TabNet: Attentive Interpretable Tabular Learning is another model coming out of Google Research which uses Sparse Attention in multiple steps of decision making to model the output.
- Mixture Density Networks is a regression model which uses gaussian components to approximate the target function and provide a probabilistic prediction out of the box.
- AutoInt: Automatic Feature Interaction Learning via Self-Attentive Neural Networks is a model which tries to learn interactions between the features in an automated way and create a better representation and then use this representation in downstream task
- TabTransformer is an adaptation of the Transformer model for Tabular Data which creates contextual representations for categorical features.
- FT Transformer from Revisiting Deep Learning Models for Tabular Data
- Gated Additive Tree Ensemble is a novel high-performance, parameter and computationally efficient deep learning architecture for tabular data. GATE uses a gating mechanism, inspired from GRU, as a feature representation learning unit with an in-built feature selection mechanism. We combine it with an ensemble of differentiable, non-linear decision trees, re-weighted with simple self-attention to predict our desired output.
- Gated Adaptive Network for Deep Automated Learning of Features (GANDALF) is pared-down version of GATE which is more efficient and performing than GATE. GANDALF makes GFLUs the main learning unit, also introducing some speed-ups in the process. With very minimal hyperparameters to tune, this becomes an easy to use and tune model.
- DANETs: Deep Abstract Networks for Tabular Data Classification and Regression is a novel and flexible neural component for tabular data, called Abstract Layer (AbstLay), which learns to explicitly group correlative input features and generate higher-level features for semantics abstraction. A special basic block is built using AbstLays, and we construct a family of Deep Abstract Networks (DANets) for tabular data classification and regression by stacking such blocks.
Semi-Supervised Learning
- Denoising AutoEncoder is an autoencoder which learns robust feature representation, to compensate any noise in the dataset.
Implement Custom Models
To implement new models, see the How to implement new models tutorial. It covers basic as well as advanced architectures.
Usage
from pytorch_tabular import TabularModel
from pytorch_tabular.models import CategoryEmbeddingModelConfig
from pytorch_tabular.config import (
DataConfig,
OptimizerConfig,
TrainerConfig,
ExperimentConfig,
)
data_config = DataConfig(
target=[
"target"
], # target should always be a list. Multi-targets are only supported for regression. Multi-Task Classification is not implemented
continuous_cols=num_col_names,
categorical_cols=cat_col_names,
)
trainer_config = TrainerConfig(
auto_lr_find=True, # Runs the LRFinder to automatically derive a learning rate
batch_size=1024,
max_epochs=100,
)
optimizer_config = OptimizerConfig()
model_config = CategoryEmbeddingModelConfig(
task="classification",
layers="1024-512-512", # Number of nodes in each layer
activation="LeakyReLU", # Activation between each layers
learning_rate=1e-3,
)
tabular_model = TabularModel(
data_config=data_config,
model_config=model_config,
optimizer_config=optimizer_config,
trainer_config=trainer_config,
)
tabular_model.fit(train=train, validation=val)
result = tabular_model.evaluate(test)
pred_df = tabular_model.predict(test)
tabular_model.save_model("examples/basic")
loaded_model = TabularModel.load_model("examples/basic")
Blogs
- PyTorch Tabular – A Framework for Deep Learning for Tabular Data
- Neural Oblivious Decision Ensembles(NODE) – A State-of-the-Art Deep Learning Algorithm for Tabular Data
- Mixture Density Networks: Probabilistic Regression for Uncertainty Estimation
Future Roadmap(Contributions are Welcome)
- Integrate Optuna Hyperparameter Tuning
- Migrate Datamodule to Polars or NVTabular for faster data loading and to handle larger than RAM datasets.
- Add GaussRank as Feature Transformation
- Have a scikit-learn compatible API
- Enable support for multi-label classification
- Keep adding more architectures
Contributors
Manu Joseph |
Jirka Borovec |
Jinu Sunil |
Soren Macbeth |
Programador Artificial |
Chris Fonnesbeck |
Null |
Andreas |
Earlee |
Null |
Kushashwa Ravi Shrimali |
Luca Actis Grosso |
Sterling G. Baird |
Yinyu Nie |
Citation
If you use PyTorch Tabular for a scientific publication, we would appreciate citations to the published software and the following paper:
@misc{joseph2021pytorch,
title={PyTorch Tabular: A Framework for Deep Learning with Tabular Data},
author={Manu Joseph},
year={2021},
eprint={2104.13638},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
- Zenodo Software Citation
@software{manu_joseph_2023_7554473,
author = {Manu Joseph and
Jinu Sunil and
Jiri Borovec and
Chris Fonnesbeck and
jxtrbtk and
Andreas and
JulianRein and
Kushashwa Ravi Shrimali and
Luca Actis Grosso and
Sterling G. Baird and
Yinyu Nie},
title = {manujosephv/pytorch\_tabular: v1.0.1},
month = jan,
year = 2023,
publisher = {Zenodo},
version = {v1.0.1},
doi = {10.5281/zenodo.7554473},
url = {https://doi.org/10.5281/zenodo.7554473}
}
History
Certainly! Here's a release update you can use for the history.md file:
1.1.0 (2024-01-15)
New Features and Enhancements
- Added DANet Model: Added a new model, DANet, for tabular data.
- Explainability: Integrated Captum for explainability
- Hyperparameter Tuner: Added Grid and Random Search functionality to search through hyperparameters and return best model.
- Model Sweep: Added an easy "Model Sweep" method with which we can sweep a list of models with given data and quickly assess performance.
- Documentation Enhancements: Improved documentation to make it more user-friendly and informative
- Dependency Updates: Updated various dependencies for improved compatibility and security
- Graceful Out-of-Memory Handling: Added graceful out-of-memory handling for tabular models
- GhostBatchNorm: Added GhostBatchNorm to the library
Deprecations
- Deprecations: Handled deprecations and updated the library accordingly
- Entmax Dependency Removed: Removed dependency on entmax
Infrastructure and CI/CD
- Continuous Integration: Improved CI with new actions and labels
- Dependency Management: Updated dependencies and restructured requirements
API Changes
- [BREAKING CHANGE] SSL API Change: Addressed SSL API change, along with documentation and tutorial updates.
- Model Changes: Added is_fitted and other markers to the tabular model.
- Custom Optimizer: Allow custom optimizer in the model config.
Contributors
- Thanks to all the contributors who helped shape this release! (List of Contributors)
Upgrading
- Ensure to check the updated documentation for any breaking changes or new features.
- If you are using SSL, please check the updated API and documentation.
1.0.2 (2023-05-31)
New Features:
- Added Feature Importance: The library now includes a new method in TabularModel and BaseModel for enabling feature importance. Feature Importance has been enabled for FTTransformer and GATE models. [Commit: dc2a49e]
Enhancements:
- Enabled two more parameters in the GATE model. [Commit: 3680413]
- Included metric_prob_input parameter in the library configuration. This update allows for better control over metrics in the models. [Commit: 0612db5]
- Slight improvements to the GATE model, including changes to defaults for better performance. [Commit: c30a6c3]
- Minor bug fixes and improvements, including accelerator options in the configuration and progress bar enhancements. [Commit: f932230, bdd9adb, f932230]
Dependency Updates:
- Updated dependencies, including docformatter, pyupgrade, and ruff-pre-commit. [Commits: 4aae9a8, b3df4ce, bdd9adb, 55e800c, c6c4679, c01154b, 107cd2f]
Documentation Updates:
- Updated the library's README.md file. [Commits: db8f3b2, cab6bf1, 669faec, 1e6c400, 3097799, 7fabf6b]
Other Improvements:
- Various code optimizations, bug fixes, and CI enhancements. [Commits: 5637020, e5171bf, 812b40f]
For more details, you can refer to the respective commits on the library's GitHub repository.
1.0.1 (2023-01-20)
- Bugfix for default metric for binary classification
1.0.0 (2023-01-18)
- Added a new task - Self Supervised Learning (SSL) and a separate training API for it.
- Added new SOTA model - Gated Additive Tree Ensembles (GATE).
- Added one SSL model - Denoising AutoEncoder.
- Added lots of new tutorials and updated entire documentation.
- Improved code documentation and type hints.
- Separated a Model into separate Embedding, Backbone, and Head.
- Refactored all models to separate Backbone as native PyTorch Model(nn.Module).
- Refactored commonly used modules (layers, activations etc. to a common module).
- Changed MixedDensityNetworks completely (breaking change). Now MDN is a head you can use with any model.
- Enabled a low level api for training model.
- Enabled saving and loading of datamodule.
- Added trainer_kwargs to pass any trainer argument PyTorch Lightning supports.
- Added Early Stopping and Model Checkpoint kwargs to use all the arguments in PyTorch Lightining.
- Enabled prediction using GPUs in predict method.
- Added
reset_model
to reset model weights to random. - Added many save and load functions including ONNX(experimental).
- Added random seed as a parameter.
- Switched over completely to Rich progressbars from tqdm.
- Fixed class-balancing / mu propagation and set default to 1.0.
- Added PyTorch Profiler for debugging performance issues.
- Fixed bugs with FTTransformer and TabTransformer.
- Updated MixedDensityNetworks fixing a bug with lambda_pi.
- Many CI/CD improvements including complete integration with GitHub Actions.
- Upgraded all dependencies, including PyTorch Lightning, pandas, to latest versions and added dependabot to manage it going forward.
- Added pre-commit to ensure code integrity and standardization.
0.7.0 (2021-09-01)
- Implemented TabTransformer and FTTransformer models
- Included capability to save a model using GPU an load in CPU
- Made the temp folder pytorch tabular specific to avoid conflicts with other tmp folders.
- Some bug fixes
- Edited an error out of Advanced Tutorial in docs
0.6.0 (2021-06-21)
- Upgraded versions of PyTorch Lightning to 1.3.6
- Changed the way
gpus
parameter is handled to avoid confusion.None
is CPU,-1
is all GPUs,int
is number of GPUs - Added a few more Trainer Params like
deterministic
,auto_select_gpus
- Some bug fixes and changes to docs
- Added
seed_everything
to the fit method to ensure reproducibility - Refactored data_aware_initialization to be part of the BaseModel. Inherited Models can override the method to implement data aware initialization techniques
0.5.0 (2021-03-18)
- Added more documentation
- Added Zenodo citation
0.4.0 (2021-03-18)
- Added AutoInt Model
- Added Mixture Density Networks
- Refactored the classes to separate backbones from the head of the models
- Changed the saving and loading model to work for custom parameters that you pass in
fit
0.3.0 (2021-03-02)
- Fixed a bug on inference
0.2.0 (2021-02-07)
- Fixed an issue with torch.clip and torch version
- Fixed an issue with
gpus
parameter in TrainerConfig, by setting default value toNone
for CPU - Added feature to use custom sampler in the training dataloader
- Updated documentation and added a new tutorial for imbalanced classification
0.0.1 (2021-01-26)
- First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytorch_tabular-1.1.0.tar.gz
.
File metadata
- Download URL: pytorch_tabular-1.1.0.tar.gz
- Upload date:
- Size: 2.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5329057bb2698a15c120ef8e2979e332db0e6ab344eb84f2460e41b50c6d4c56 |
|
MD5 | a2bc5c70b90f91043e263e04b0b5732b |
|
BLAKE2b-256 | 3247c29228a05b1126d1f536a9969ee2b1def0f8537978b4187826908bdbf99d |
File details
Details for the file pytorch_tabular-1.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: pytorch_tabular-1.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 160.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aae13590cdb916a1d6ad966eefa363ff1529e2ecbab994c42ec9240269321a57 |
|
MD5 | a4daebe97cbad4a130fd757058b698b4 |
|
BLAKE2b-256 | cfb4375b18206768d47afdd22c094ab554e3039d83cb7e358907816554fca469 |