TabNet: Attentive Interpretable Tabular Learning
TabNet is a deep learning architecture designed specifically for tabular data, combining interpretability and high predictive performance. This package provides a modern, maintained implementation of TabNet in PyTorch, supporting classification, regression, multitask learning, and unsupervised pretraining.
Installation
Install TabNet using pip:
pip install pytorch-tabnet2
What is TabNet?
TabNet is an interpretable neural network architecture for tabular data, introduced by Arik & Pfister (2019). It uses sequential attention to select which features to reason from at each decision step, enabling both high performance and interpretability. TabNet learns sparse feature masks, allowing users to understand which features are most important for each prediction. The method is particularly effective for structured/tabular datasets where traditional deep learning models often underperform compared to tree-based methods.
Key aspects of TabNet:
- Attentive Feature Selection: At each step, TabNet learns which features to focus on, improving both accuracy and interpretability.
- Interpretable Masks: The model produces feature masks that highlight the importance of each feature for individual predictions.
- End-to-End Learning: Supports classification, regression, multitask, and unsupervised pretraining tasks.
What problems does pytorch-tabnet handle?
- TabNetClassifier : binary classification and multi-class classification problems.
- TabNetRegressor : simple and multi-task regression problems.
- TabNetMultiTaskClassifier: multi-task multi-classification problems.
- MultiTabNetRegressor: multi-task regression problems, which is basically TabNetRegressor with multiple targets.
Usage
Documentation
Basic Examples
Classification
import numpy as np
from pytorch_tabnet import TabNetClassifier
# Generate dummy data
X_train = np.random.rand(100, 10)
y_train = np.random.randint(0, 2, 100)
X_valid = np.random.rand(20, 10)
y_valid = np.random.randint(0, 2, 20)
X_test = np.random.rand(10, 10)
clf = TabNetClassifier()
clf.fit(X_train, y_train, eval_set=[(X_valid, y_valid)])
preds = clf.predict(X_test)
print('Predictions:', preds)
Regression
import numpy as np
from pytorch_tabnet import TabNetRegressor
# Generate dummy data
X_train = np.random.rand(100, 10)
y_train = np.random.rand(100).reshape(-1, 1)
X_valid = np.random.rand(20, 10)
y_valid = np.random.rand(20).reshape(-1, 1)
X_test = np.random.rand(10, 10)
reg = TabNetRegressor()
reg.fit(X_train, y_train, eval_set=[(X_valid, y_valid)])
preds = reg.predict(X_test)
print('Predictions:', preds)
Multi-task Classification
import numpy as np
from pytorch_tabnet import TabNetMultiTaskClassifier
# Generate dummy data
X_train = np.random.rand(100, 10)
y_train = np.random.randint(0, 2, (100, 3)) # 3 tasks
X_valid = np.random.rand(20, 10)
y_valid = np.random.randint(0, 2, (20, 3))
X_test = np.random.rand(10, 10)
clf = TabNetMultiTaskClassifier()
clf.fit(X_train, y_train, eval_set=[(X_valid, y_valid)])
preds = clf.predict(X_test)
print('Predictions:', preds)
See the nbs/ folder for more complete examples and notebooks.
Further Reading
- TabNet: Attentive Interpretable Tabular Learning (Arik & Pfister, 2019)
- Original repo: https://github.com/dreamquark-ai/tabnet
License & Credits
- Original implementation and research by DreamQuark team
- Maintained and improved by Daniel Avdar and contributors
- See LICENSE for details
Metadata
Release files for pytorch-tabnet2 4.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytorch_tabnet2-4.6.0.tar.gz | 40.1 kB | Without provenance | Details for pytorch_tabnet2-4.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytorch_tabnet2-4.6.0-py3-none-any.whl | Python 3 | none | any | Details for pytorch_tabnet2-4.6.0-py3-none-any.whl |
Total release size: 111.0 kB
Release files / pytorch_tabnet2-4.6.0.tar.gz
| Download URL | pytorch_tabnet2-4.6.0.tar.gz |
|---|---|
| Size | 40.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1bd223655932a513a91b23a50a7044b60656507225daabda65689a18e549b5b0
|
|
BLAKE2b-256 checksum How to use checksums |
14a1cfef6063f17bc681988a277d3644eec2c05aa16d089f2dece2bce98b6262
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pytorch_tabnet2-4.6.0-py3-none-any.whl
| Download URL | pytorch_tabnet2-4.6.0-py3-none-any.whl |
|---|---|
| Size | 70.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f2cb42810258baf04cc0940164814b26ba8d9251557604ba1253e8a904364764
|
|
BLAKE2b-256 checksum How to use checksums |
81340d27f7770e60b28401c853e9938c42bc1d1bb704c3bb49412d5d49707d3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for pytorch-tabnet2 4.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.