diff --git a/docs/_modules/pytorch_tabnet/metrics.html b/docs/_modules/pytorch_tabnet/metrics.html
index d807616e..267c5532 100644
--- a/docs/_modules/pytorch_tabnet/metrics.html
+++ b/docs/_modules/pytorch_tabnet/metrics.html
@@ -82,14 +82,17 @@
-
"""
errors = y_pred - embedded_x
reconstruction_errors = torch.mul(errors, obf_vars) ** 2
- batch_stds = torch.std(embedded_x, dim=0) ** 2 + eps
+ batch_means = torch.mean(embedded_x, dim=0)
+ batch_means[batch_means == 0] = 1
+
+ batch_stds = torch.std(embedded_x, dim=0) ** 2
+ batch_stds[batch_stds == 0] = batch_means[batch_stds == 0]
features_loss = torch.matmul(reconstruction_errors, 1 / batch_stds)
# compute the number of obfuscated variables to reconstruct
nb_reconstructed_variables = torch.sum(obf_vars, dim=1)
@@ -208,6 +215,24 @@ Source code for pytorch_tabnet.metrics
+[docs]def UnsupervisedLossNumpy(y_pred, embedded_x, obf_vars, eps=1e-9):
+
errors = y_pred - embedded_x
+
reconstruction_errors = np.multiply(errors, obf_vars) ** 2
+
batch_means = np.mean(embedded_x, axis=0)
+
batch_means = np.where(batch_means == 0, 1, batch_means)
+
+
batch_stds = np.std(embedded_x, axis=0, ddof=1) ** 2
+
batch_stds = np.where(batch_stds == 0, batch_means, batch_stds)
+
features_loss = np.matmul(reconstruction_errors, 1 / batch_stds)
+
# compute the number of obfuscated variables to reconstruct
+
nb_reconstructed_variables = np.sum(obf_vars, axis=1)
+
# take the mean of the reconstructed variable errors
+
features_loss = features_loss / (nb_reconstructed_variables + eps)
+
# here we take the mean per batch, contrary to the paper
+
loss = np.mean(features_loss)
+
return loss
+
+
[docs]@dataclass
class UnsupMetricContainer:
"""Container holding a list of metrics.
@@ -571,6 +596,41 @@
Source code for pytorch_tabnet.metrics
+
[docs]class UnsupervisedNumpyMetric(Metric):
+
"""
+
Unsupervised metric
+
"""
+
+
def __init__(self):
+
self._name = "unsup_loss_numpy"
+
self._maximize = False
+
+
def __call__(self, y_pred, embedded_x, obf_vars):
+
"""
+
Compute MSE (Mean Squared Error) of predictions.
+
+
Parameters
+
----------
+
y_pred : torch.Tensor or np.array
+
Reconstructed prediction (with embeddings)
+
embedded_x : torch.Tensor
+
Original input embedded by network
+
obf_vars : torch.Tensor
+
Binary mask for obfuscated variables.
+
1 means the variables was obfuscated so reconstruction is based on this.
+
+
Returns
+
-------
+
float
+
MSE of predictions vs targets.
+
"""
+
return UnsupervisedLossNumpy(
+
y_pred,
+
embedded_x,
+
obf_vars
+
)
+
+
[docs]class RMSE(Metric):
"""
Root Mean Squared Error.
diff --git a/docs/_modules/pytorch_tabnet/multiclass_utils.html b/docs/_modules/pytorch_tabnet/multiclass_utils.html
index e579c068..0a68885b 100644
--- a/docs/_modules/pytorch_tabnet/multiclass_utils.html
+++ b/docs/_modules/pytorch_tabnet/multiclass_utils.html
@@ -82,14 +82,17 @@
-
Contents:
+
Contents:
diff --git a/docs/_modules/pytorch_tabnet/multitask.html b/docs/_modules/pytorch_tabnet/multitask.html
index 067feb01..e16ee2e6 100644
--- a/docs/_modules/pytorch_tabnet/multitask.html
+++ b/docs/_modules/pytorch_tabnet/multitask.html
@@ -82,14 +82,17 @@
-
Contents:
+
Contents:
diff --git a/docs/_modules/pytorch_tabnet/pretraining.html b/docs/_modules/pytorch_tabnet/pretraining.html
index 9244752b..a4f95e74 100644
--- a/docs/_modules/pytorch_tabnet/pretraining.html
+++ b/docs/_modules/pytorch_tabnet/pretraining.html
@@ -82,14 +82,17 @@
-
Contents:
+
Contents:
@@ -158,13 +161,13 @@
Source code for pytorch_tabnet.pretraining
import torch
import numpy as np
-from sklearn.utils import check_array
from torch.utils.data import DataLoader
from pytorch_tabnet import tab_network
from pytorch_tabnet.utils import (
create_explain_matrix,
filter_weights,
- PredictDataset
+ PredictDataset,
+ check_input
)
from torch.nn.utils import clip_grad_norm_
from pytorch_tabnet.pretraining_utils import (
@@ -184,7 +187,7 @@ Source code for pytorch_tabnet.pretraining
super(TabNetPretrainer, self).__post_init__()
self._task = 'unsupervised'
self._default_loss = UnsupervisedLoss
- self._default_metric = 'unsup_loss'
+ self._default_metric = 'unsup_loss_numpy'
[docs] def prepare_target(self, y):
return y
@@ -213,9 +216,10 @@ Source code for pytorch_tabnet.pretraining
batch_size=1024,
virtual_batch_size=128,
num_workers=0,
- drop_last=False,
+ drop_last=True,
callbacks=None,
pin_memory=True,
+ warm_start=False
):
"""Train a neural network stored in self.network
Using train_dataloader for training data and
@@ -276,7 +280,7 @@ Source code for pytorch_tabnet.pretraining
else:
self.loss_fn = loss_fn
- check_array(X_train)
+ check_input(X_train)
self.update_fit_params(
weights,
@@ -288,8 +292,10 @@ Source code for pytorch_tabnet.pretraining
X_train, eval_set
)
- if not hasattr(self, 'network'):
+ if not hasattr(self, "network") or not warm_start:
+ # model has never been fitted before of warm_start is False
self._set_network()
+
self._update_network_params()
self._set_metrics(eval_names)
self._set_optimizer()
@@ -326,6 +332,7 @@ Source code for pytorch_tabnet.pretraining
"""Setup the network and explain matrix."""
if not hasattr(self, 'pretraining_ratio'):
self.pretraining_ratio = 0.5
+ torch.manual_seed(self.seed)
self.network = tab_network.TabNetPretraining(
self.input_dim,
pretraining_ratio=self.pretraining_ratio,
@@ -495,9 +502,9 @@ Source code for pytorch_tabnet.pretraining
# Main loop
for batch_idx, X in enumerate(loader):
output, embedded_x, obf_vars = self._predict_batch(X)
- list_output.append(output)
- list_embedded_x.append(embedded_x)
- list_obfuscation.append(obf_vars)
+ list_output.append(output.cpu().detach().numpy())
+ list_embedded_x.append(embedded_x.cpu().detach().numpy())
+ list_obfuscation.append(obf_vars.cpu().detach().numpy())
output, embedded_x, obf_vars = self.stack_batches(list_output,
list_embedded_x,
@@ -526,9 +533,9 @@ Source code for pytorch_tabnet.pretraining
return self.network(X)
[docs] def stack_batches(self, list_output, list_embedded_x, list_obfuscation):
-
output = torch.cat(list_output, axis=0)
-
embedded_x = torch.cat(list_embedded_x, axis=0)
-
obf_vars = torch.cat(list_obfuscation, axis=0)
+
output = np.vstack(list_output)
+
embedded_x = np.vstack(list_embedded_x)
+
obf_vars = np.vstack(list_obfuscation)
return output, embedded_x, obf_vars
[docs] def predict(self, X):
diff --git a/docs/_modules/pytorch_tabnet/pretraining_utils.html b/docs/_modules/pytorch_tabnet/pretraining_utils.html
index 43c1af09..1234f03b 100644
--- a/docs/_modules/pytorch_tabnet/pretraining_utils.html
+++ b/docs/_modules/pytorch_tabnet/pretraining_utils.html
@@ -82,14 +82,17 @@
-
Contents:
+
Contents:
@@ -160,8 +163,8 @@
Source code for pytorch_tabnet.pretraining_utils
from pytorch_tabnet.utils import (
create_sampler,
PredictDataset,
+
check_input
)
-
from sklearn.utils import check_array
[docs]def create_dataloaders(
@@ -251,7 +254,7 @@
Source code for pytorch_tabnet.pretraining_utils
), "eval_set and eval_name have not the same length"
for set_nb, X in enumerate(eval_set):
-
check_array(X)
+
check_input(X)
msg = (
f"Number of columns is different between eval set {set_nb}"
+ f"({X.shape[1]}) and X_train ({X_train.shape[1]})"
diff --git a/docs/_modules/pytorch_tabnet/sparsemax.html b/docs/_modules/pytorch_tabnet/sparsemax.html
index 0595e900..8f03e2ea 100644
--- a/docs/_modules/pytorch_tabnet/sparsemax.html
+++ b/docs/_modules/pytorch_tabnet/sparsemax.html
@@ -82,14 +82,17 @@
-
Contents:
+
Contents:
diff --git a/docs/_modules/pytorch_tabnet/tab_model.html b/docs/_modules/pytorch_tabnet/tab_model.html
index 4c926370..d8bf5379 100644
--- a/docs/_modules/pytorch_tabnet/tab_model.html
+++ b/docs/_modules/pytorch_tabnet/tab_model.html
@@ -82,14 +82,17 @@
-
Contents:
+
Contents:
diff --git a/docs/_modules/pytorch_tabnet/tab_network.html b/docs/_modules/pytorch_tabnet/tab_network.html
index 81f9d77e..c8ba7358 100644
--- a/docs/_modules/pytorch_tabnet/tab_network.html
+++ b/docs/_modules/pytorch_tabnet/tab_network.html
@@ -82,14 +82,17 @@
-
Contents:
+
Contents:
@@ -364,8 +367,8 @@
Source code for pytorch_tabnet.tab_network
input_dim,
n_d=8,
n_steps=3,
- n_independent=2,
- n_shared=2,
+ n_independent=1,
+ n_shared=1,
virtual_batch_size=128,
momentum=0.02,
):
@@ -386,9 +389,9 @@ Source code for pytorch_tabnet.tab_network
gamma : float
Float above 1, scaling factor for attention updates (usually between 1.0 to 2.0)
n_independent : int
- Number of independent GLU layer in each GLU block (default 2)
+ Number of independent GLU layer in each GLU block (default 1)
n_shared : int
- Number of independent GLU layer in each GLU block (default 2)
+ Number of independent GLU layer in each GLU block (default 1)
virtual_batch_size : int
Batch size for Ghost Batch Normalization
momentum : float
@@ -403,7 +406,6 @@ Source code for pytorch_tabnet.tab_network
self.virtual_batch_size = virtual_batch_size
self.feat_transformers = torch.nn.ModuleList()
- self.reconstruction_layers = torch.nn.ModuleList()
if self.n_shared > 0:
shared_feat_transform = torch.nn.ModuleList()
@@ -426,16 +428,16 @@ Source code for pytorch_tabnet.tab_network
momentum=momentum,
)
self.feat_transformers.append(transformer)
- reconstruction_layer = Linear(n_d, self.input_dim, bias=False)
- initialize_non_glu(reconstruction_layer, n_d, self.input_dim)
- self.reconstruction_layers.append(reconstruction_layer)
+
+ self.reconstruction_layer = Linear(n_d, self.input_dim, bias=False)
+ initialize_non_glu(self.reconstruction_layer, n_d, self.input_dim)
[docs] def forward(self, steps_output):
res = 0
for step_nb, step_output in enumerate(steps_output):
x = self.feat_transformers[step_nb](step_output)
-
x = self.reconstruction_layers[step_nb](step_output)
res = torch.add(res, x)
+
res = self.reconstruction_layer(res)
return res
@@ -457,6 +459,8 @@ Source code for pytorch_tabnet.tab_network
virtual_batch_size=128,
momentum=0.02,
mask_type="sparsemax",
+ n_shared_decoder=1,
+ n_indep_decoder=1,
):
super(TabNetPretraining, self).__init__()
@@ -474,6 +478,8 @@ Source code for pytorch_tabnet.tab_network
self.n_shared = n_shared
self.mask_type = mask_type
self.pretraining_ratio = pretraining_ratio
+ self.n_shared_decoder = n_shared_decoder
+ self.n_indep_decoder = n_indep_decoder
if self.n_steps <= 0:
raise ValueError("n_steps should be a positive integer.")
@@ -503,8 +509,8 @@ Source code for pytorch_tabnet.tab_network
self.post_embed_dim,
n_d=n_d,
n_steps=n_steps,
- n_independent=n_independent,
- n_shared=n_shared,
+ n_independent=self.n_indep_decoder,
+ n_shared=self.n_shared_decoder,
virtual_batch_size=virtual_batch_size,
momentum=momentum,
)
@@ -952,10 +958,19 @@ Source code for pytorch_tabnet.tab_network
If int, the same embedding dimension will be used for all categorical features
"""
super(EmbeddingGenerator, self).__init__()
- if cat_dims == [] or cat_idxs == []:
+ if cat_dims == [] and cat_idxs == []:
self.skip_embedding = True
self.post_embed_dim = input_dim
return
+ elif (cat_dims == []) ^ (cat_idxs == []):
+ if cat_dims == []:
+ msg = "If cat_idxs is non-empty, cat_dims must be defined as a list of same length."
+ else:
+ msg = "If cat_dims is non-empty, cat_idxs must be defined as a list of same length."
+ raise ValueError(msg)
+ elif len(cat_dims) != len(cat_idxs):
+ msg = "The lists cat_dims and cat_idxs must have the same length."
+ raise ValueError(msg)
self.skip_embedding = False
if isinstance(cat_emb_dim, int):
diff --git a/docs/_modules/pytorch_tabnet/utils.html b/docs/_modules/pytorch_tabnet/utils.html
index a9c18e4f..17205ca8 100644
--- a/docs/_modules/pytorch_tabnet/utils.html
+++ b/docs/_modules/pytorch_tabnet/utils.html
@@ -82,14 +82,17 @@
- Contents:
+ Contents:
@@ -163,6 +166,8 @@
Source code for pytorch_tabnet.utils
import scipy
import json
from sklearn.utils import check_array
+import pandas as pd
+import warnings
[docs]class TorchDataset(Dataset):
@@ -429,7 +434,7 @@
Source code for pytorch_tabnet.utils
len(elem) == 2 for elem in eval_set
), "Each tuple of eval_set need to have two elements"
for name, (X, y) in zip(eval_name, eval_set):
- check_array(X)
+ check_input(X)
msg = (
f"Dimension mismatch between X_{name} "
+ f"{X.shape} and X_train {X_train.shape}"
@@ -495,6 +500,28 @@ Source code for pytorch_tabnet.utils
return int(obj)
# Let the base class default method raise the TypeError
return json.JSONEncoder.default(self, obj)
+
+
+
+
+
+
[docs]def check_warm_start(warm_start, from_unsupervised):
+
"""
+
Gives a warning about ambiguous usage of the two parameters.
+
"""
+
if warm_start and from_unsupervised is not None:
+
warn_msg = "warm_start=True and from_unsupervised != None: "
+
warn_msg = "warm_start will be ignore, training will start from unsupervised weights"
+
warnings.warn(warn_msg)
+
return
diff --git a/docs/_modules/torch/optim/adam.html b/docs/_modules/torch/optim/adam.html
index 2f5a4891..7871f583 100644
--- a/docs/_modules/torch/optim/adam.html
+++ b/docs/_modules/torch/optim/adam.html
@@ -82,14 +82,17 @@
-
Contents:
+
Contents:
diff --git a/docs/_sources/generated_docs/README.md.txt b/docs/_sources/generated_docs/README.md.txt
index 049c9c49..0f0954bb 100644
--- a/docs/_sources/generated_docs/README.md.txt
+++ b/docs/_sources/generated_docs/README.md.txt
@@ -4,21 +4,48 @@
This is a pyTorch implementation of Tabnet (Arik, S. O., & Pfister, T. (2019). TabNet: Attentive Interpretable Tabular Learning. arXiv preprint arXiv:1908.07442.) https://arxiv.org/pdf/1908.07442.pdf.
+
[![CircleCI](https://circleci.com/gh/dreamquark-ai/tabnet.svg?style=svg)](https://circleci.com/gh/dreamquark-ai/tabnet)
[![PyPI version](https://badge.fury.io/py/pytorch-tabnet.svg)](https://badge.fury.io/py/pytorch-tabnet)
![PyPI - Downloads](https://img.shields.io/pypi/dm/pytorch-tabnet)
+[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pytorch-tabnet?logo=pypi&style=flat&color=blue)][#pypi-package]
+
+[![Conda - Platform](https://img.shields.io/conda/pn/conda-forge/pytorch-tabnet?logo=anaconda&style=flat)][#conda-forge-package]
+
+[![Conda (channel only)](https://img.shields.io/conda/vn/conda-forge/pytorch-tabnet?logo=anaconda&style=flat&color=orange)][#conda-forge-package]
+
+[![GitHub - License](https://img.shields.io/github/license/dreamquark-ai/tabnet?logo=github&style=flat&color=green)][#github-license]
+
+[#github-license]: https://github.com/dreamquark-ai/tabnet/blob/main/LICENSE
+[#pypi-package]: https://pypi.org/project/pytorch-tabnet/
+[#conda-forge-package]: https://anaconda.org/conda-forge/pytorch-tabnet
+
+
Any questions ? Want to contribute ? To talk with us ? You can join us on [Slack](https://join.slack.com/t/mltooling/shared_invite/zt-fxaj0qk7-SWy2_~EWyhj4x9SD6gbRvg)
# Installation
## Easy installation
-You can install using pip by running:
-`pip install pytorch-tabnet`
+
+You can install using `pip` or `conda` as follows.
+
+**with pip**
+
+```sh
+pip install pytorch-tabnet
+```
+
+**with conda**
+
+```sh
+conda install -c conda-forge pytorch-tabnet
+```
## Source code
+
If you wan to use it locally within a docker container:
- `git clone git@github.com:dreamquark-ai/tabnet.git`
@@ -26,18 +53,28 @@ If you wan to use it locally within a docker container:
- `cd tabnet` to get inside the repository
-----------------
+
#### CPU only
+
- `make start` to build and get inside the container
#### GPU
+
- `make start-gpu` to build and get inside the GPU container
-----------------
+
- `poetry install` to install all the dependencies, including jupyter
- `make notebook` inside the same terminal. You can then follow the link to a jupyter notebook with tabnet installed.
-# What problems does pytorch-tabnet handles?
+# Contributing
+
+When contributing to the TabNet repository, please make sure to first discuss the change you wish to make via a new or already existing issue.
+
+Our commits follow the rules presented [here](https://www.conventionalcommits.org/en/v1.0.0/).
+
+# What problems does pytorch-tabnet handle?
- TabNetClassifier : binary classification and multi-class classification problems
- TabNetRegressor : simple and multi-task regression problems
@@ -70,11 +107,11 @@ clf.fit(
preds = clf.predict(X_test)
```
-The targets on `y_train/y_valid` should contain a unique type (i.e. they must all be strings or integers).
+The targets on `y_train/y_valid` should contain a unique type (e.g. they must all be strings or integers).
### Default eval_metric
-A few classical evaluation metrics are implemented (see bellow section for custom ones):
+A few classic evaluation metrics are implemented (see further below for custom ones):
- binary classification metrics : 'auc', 'accuracy', 'balanced_accuracy', 'logloss'
- multiclass classification : 'accuracy', 'balanced_accuracy', 'logloss'
- regression: 'mse', 'mae', 'rmse', 'rmsle'
@@ -86,7 +123,7 @@ In order to match the given scores, you need to use `np.clip(clf.predict(X_predi
### Custom evaluation metrics
-It's easy to create a metric that matches your specific need. Here is an example for gini score (note that you need to specifiy whether this metric should be maximized or not):
+You can create a metric for your specific need. Here is an example for gini score (note that you need to specifiy whether this metric should be maximized or not):
```python
from pytorch_tabnet.metrics import Metric
@@ -148,13 +185,31 @@ clf.fit(
)
```
-The loss function has been normalized to be independent of `pretraining_ratio`, `batch_size` and number of features in the problem.
+The loss function has been normalized to be independent of `pretraining_ratio`, `batch_size` and the number of features in the problem.
A self supervised loss greater than 1 means that your model is reconstructing worse than predicting the mean for each feature, a loss bellow 1 means that the model is doing better than predicting the mean.
A complete example can be found within the notebook `pretraining_example.ipynb`.
/!\ : current implementation is trying to reconstruct the original inputs, but Batch Normalization applies a random transformation that can't be deduced by a single line, making the reconstruction harder. Lowering the `batch_size` might make the pretraining easier.
+# Data augmentation on the fly
+
+It is now possible to apply custom data augmentation pipeline during training.
+Templates for ClassificationSMOTE and RegressionSMOTE have been added in `pytorch-tabnet/augmentations.py` and can be used as is.
+
+
+# Easy saving and loading
+
+It's really easy to save and re-load a trained model, this makes TabNet production ready.
+```
+# save tabnet model
+saving_path_name = "./tabnet_model_test_1"
+saved_filepath = clf.save_model(saving_path_name)
+
+# define new model with basic parameters and load state dict weights
+loaded_clf = TabNetClassifier()
+loaded_clf.load_model(saved_filepath)
+```
# Useful links
@@ -237,7 +292,7 @@ A complete example can be found within the notebook `pretraining_example.ipynb`.
- `optimizer_params`: dict (default=dict(lr=2e-2))
- Parameters compatible with optimizer_fn used initialize the optimizer. Since we have Adam as our default optimizer, we use this to define the initial learning rate used for training. As mentionned in the original paper, a large initial learning of ```0.02 ``` with decay is a good option.
+ Parameters compatible with optimizer_fn used initialize the optimizer. Since we have Adam as our default optimizer, we use this to define the initial learning rate used for training. As mentionned in the original paper, a large initial learning rate of ```0.02 ``` with decay is a good option.
- `scheduler_fn` : torch.optim.lr_scheduler (default=None)
@@ -251,10 +306,6 @@ A complete example can be found within the notebook `pretraining_example.ipynb`.
Name of the model used for saving in disk, you can customize this to easily retrieve and reuse your trained models.
-- `saving_path` : str (default = './')
-
- Path defining where to save models.
-
- `verbose` : int (default=1)
Verbosity for notebooks plots, set to 1 to see every epoch, 0 to get None.
@@ -263,7 +314,15 @@ A complete example can be found within the notebook `pretraining_example.ipynb`.
'cpu' for cpu training, 'gpu' for gpu training, 'auto' to automatically detect gpu.
- `mask_type: str` (default='sparsemax')
- Either "sparsemax" or "entmax" : this is the masking function to use for selecting features
+ Either "sparsemax" or "entmax" : this is the masking function to use for selecting features.
+
+- `n_shared_decoder` : int (default=1)
+
+ Number of shared GLU block in decoder, this is only useful for `TabNetPretrainer`.
+
+- `n_indep_decoder` : int (default=1)
+
+ Number of independent GLU block in decoder, this is only useful for `TabNetPretrainer`.
## Fit parameters
@@ -291,13 +350,13 @@ A complete example can be found within the notebook `pretraining_example.ipynb`.
Maximum number of epochs for trainng.
-- `patience` : int (default = 15)
+- `patience` : int (default = 10)
Number of consecutive epochs without improvement before performing early stopping.
- If patience is set to 0 then no early stopping will be performed.
+ If patience is set to 0, then no early stopping will be performed.
- Note that if patience is enabled, best weights from best epoch will automatically be loaded at the end of `fit`.
+ Note that if patience is enabled, then best weights from best epoch will automatically be loaded at the end of `fit`.
- `weights` : int or dict (default=0)
@@ -315,7 +374,7 @@ A complete example can be found within the notebook `pretraining_example.ipynb`.
- `batch_size` : int (default=1024)
- Number of examples per batch, large batch sizes are recommended.
+ Number of examples per batch. Large batch sizes are recommended.
- `virtual_batch_size` : int (default=128)
@@ -338,3 +397,7 @@ A complete example can be found within the notebook `pretraining_example.ipynb`.
/!\ TabNetPretrainer Only : Percentage of input features to mask during pretraining.
Should be between 0 and 1. The bigger the harder the reconstruction task is.
+
+- `warm_start` : bool (default=False)
+ In order to match scikit-learn API, this is set to False.
+ It allows to fit twice the same model and start from a warm start.
diff --git a/docs/_sources/generated_docs/pytorch_tabnet.rst.txt b/docs/_sources/generated_docs/pytorch_tabnet.rst.txt
index 9eca1050..18680c50 100644
--- a/docs/_sources/generated_docs/pytorch_tabnet.rst.txt
+++ b/docs/_sources/generated_docs/pytorch_tabnet.rst.txt
@@ -2,19 +2,19 @@ pytorch_tabnet package
======================
-pytorch_tabnet.utils module
-.............................
+pytorch_tabnet.pretraining_utils module
+.........................................
-.. automodule:: pytorch_tabnet.utils
+.. automodule:: pytorch_tabnet.pretraining_utils
:members:
:undoc-members:
:show-inheritance:
-pytorch_tabnet.pretraining_utils module
-.........................................
+pytorch_tabnet.augmentations module
+.....................................
-.. automodule:: pytorch_tabnet.pretraining_utils
+.. automodule:: pytorch_tabnet.augmentations
:members:
:undoc-members:
:show-inheritance:
@@ -29,28 +29,37 @@ pytorch_tabnet.tab_network module
:show-inheritance:
-pytorch_tabnet.multitask module
+pytorch_tabnet.metrics module
+...............................
+
+.. automodule:: pytorch_tabnet.metrics
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+
+pytorch_tabnet.tab_model module
.................................
-.. automodule:: pytorch_tabnet.multitask
+.. automodule:: pytorch_tabnet.tab_model
:members:
:undoc-members:
:show-inheritance:
-pytorch_tabnet.multiclass_utils module
-........................................
+pytorch_tabnet.sparsemax module
+.................................
-.. automodule:: pytorch_tabnet.multiclass_utils
+.. automodule:: pytorch_tabnet.sparsemax
:members:
:undoc-members:
:show-inheritance:
-pytorch_tabnet.tab_model module
+pytorch_tabnet.callbacks module
.................................
-.. automodule:: pytorch_tabnet.tab_model
+.. automodule:: pytorch_tabnet.callbacks
:members:
:undoc-members:
:show-inheritance:
@@ -65,37 +74,37 @@ pytorch_tabnet.abstract_model module
:show-inheritance:
-pytorch_tabnet.callbacks module
-.................................
+pytorch_tabnet.pretraining module
+...................................
-.. automodule:: pytorch_tabnet.callbacks
+.. automodule:: pytorch_tabnet.pretraining
:members:
:undoc-members:
:show-inheritance:
-pytorch_tabnet.pretraining module
-...................................
+pytorch_tabnet.utils module
+.............................
-.. automodule:: pytorch_tabnet.pretraining
+.. automodule:: pytorch_tabnet.utils
:members:
:undoc-members:
:show-inheritance:
-pytorch_tabnet.sparsemax module
+pytorch_tabnet.multitask module
.................................
-.. automodule:: pytorch_tabnet.sparsemax
+.. automodule:: pytorch_tabnet.multitask
:members:
:undoc-members:
:show-inheritance:
-pytorch_tabnet.metrics module
-...............................
+pytorch_tabnet.multiclass_utils module
+........................................
-.. automodule:: pytorch_tabnet.metrics
+.. automodule:: pytorch_tabnet.multiclass_utils
:members:
:undoc-members:
:show-inheritance:
diff --git a/docs/_static/pygments.css b/docs/_static/pygments.css
index d14395ef..691aeb82 100644
--- a/docs/_static/pygments.css
+++ b/docs/_static/pygments.css
@@ -1,8 +1,8 @@
-pre { line-height: 125%; margin: 0; }
-td.linenos pre { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
-span.linenos { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
-td.linenos pre.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
-span.linenos.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
+pre { line-height: 125%; }
+td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
+span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
+td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
+span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight { background: #eeffcc; }
.highlight .c { color: #408090; font-style: italic } /* Comment */
diff --git a/docs/generated_docs/README.html b/docs/generated_docs/README.html
index 329f3a77..f6deca28 100644
--- a/docs/generated_docs/README.html
+++ b/docs/generated_docs/README.html
@@ -4,7 +4,8 @@
-
+
+
README — pytorch_tabnet documentation
@@ -84,7 +85,7 @@
-
Contents:
+
Contents:
-
What problems does pytorch-tabnet handles?
+
Contributing
+
What problems does pytorch-tabnet handle?
How to use it?
Semi-supervised pre-training
+
Data augmentation on the fly
+
Easy saving and loading
Useful links
- Model parameters
- Fit parameters
@@ -175,25 +179,36 @@
-
+
-
+
+
TabNet : Attentive Interpretable Tabular Learning
This is a pyTorch implementation of Tabnet (Arik, S. O., & Pfister, T. (2019). TabNet: Attentive Interpretable Tabular Learning. arXiv preprint arXiv:1908.07442.) https://arxiv.org/pdf/1908.07442.pdf.
-![CircleCI](https://circleci.com/gh/dreamquark-ai/tabnet.svg?style=svg)
+![CircleCI](https://circleci.com/gh/dreamquark-ai/tabnet.svg?style=svg)
![PyPI version](https://badge.fury.io/py/pytorch-tabnet.svg)
![PyPI - Downloads](https://img.shields.io/pypi/dm/pytorch-tabnet)
-Any questions ? Want to contribute ? To talk with us ? You can join us on Slack
-
-
+
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pytorch-tabnet?logo=pypi&style=flat&color=blue)
+
![Conda - Platform](https://img.shields.io/conda/pn/conda-forge/pytorch-tabnet?logo=anaconda&style=flat)
+
![Conda (channel only)](https://img.shields.io/conda/vn/conda-forge/pytorch-tabnet?logo=anaconda&style=flat&color=orange)
+
![GitHub - License](https://img.shields.io/github/license/dreamquark-ai/tabnet?logo=github&style=flat&color=green)
+
Any questions ? Want to contribute ? To talk with us ? You can join us on Slack
+
+
Installation
-
+
Easy installation
-You can install using pip by running:
-pip install pytorch-tabnet
+You can install using pip
or conda
as follows.
+with pip
+pip install pytorch-tabnet
+
-
+
with conda
+
conda install -c conda-forge pytorch-tabnet
+
+
+
+
Source code
If you wan to use it locally within a docker container:
@@ -201,13 +216,13 @@ Source code
-
-
-
-
-
-
What problems does pytorch-tabnet handles?
+
+
+
+
+Contributing
+When contributing to the TabNet repository, please make sure to first discuss the change you wish to make via a new or already existing issue.
+Our commits follow the rules presented here.
+
+
+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
-
-
+
+
How to use it?
TabNet is now scikit-compatible, training a TabNetClassifier or TabNetRegressor is really easy.
from pytorch_tabnet.tab_model import TabNetClassifier, TabNetRegressor
@@ -251,10 +271,10 @@ How to use it?
-The targets on y_train/y_valid
should contain a unique type (i.e. they must all be strings or integers).
-
+
The targets on y_train/y_valid
should contain a unique type (e.g. they must all be strings or integers).
+
Default eval_metric
-A few classical evaluation metrics are implemented (see bellow section for custom ones):
+A few classic evaluation metrics are implemented (see further below for custom ones):
binary classification metrics : ‘auc’, ‘accuracy’, ‘balanced_accuracy’, ‘logloss’
multiclass classification : ‘accuracy’, ‘balanced_accuracy’, ‘logloss’
@@ -262,10 +282,10 @@ Default eval_metric
-
+
+
Custom evaluation metrics
-It’s easy to create a metric that matches your specific need. Here is an example for gini score (note that you need to specifiy whether this metric should be maximized or not):
+You can create a metric for your specific need. Here is an example for gini score (note that you need to specifiy whether this metric should be maximized or not):
from pytorch_tabnet.metrics import Metric
from sklearn.metrics import roc_auc_score
@@ -287,9 +307,9 @@ Custom evaluation metrics
diff --git a/docs/generated_docs/pytorch_tabnet.html b/docs/generated_docs/pytorch_tabnet.html
index 5583b3b0..2aefc158 100644
--- a/docs/generated_docs/pytorch_tabnet.html
+++ b/docs/generated_docs/pytorch_tabnet.html
@@ -4,7 +4,8 @@
-
+
+
pytorch_tabnet package — pytorch_tabnet documentation
@@ -83,30 +84,34 @@
-
Contents:
+
Contents:
@@ -174,208 +179,9 @@
-
+
pytorch_tabnet package
-
-
pytorch_tabnet.utils module
-
--
-class
pytorch_tabnet.utils.
ComplexEncoder
(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]
-Bases: json.encoder.JSONEncoder
-
--
-
default
(obj)[source]
-Implement this method in a subclass such that it returns
-a serializable object for o
, or calls the base implementation
-(to raise a TypeError
).
-For example, to support arbitrary iterators, you could
-implement default like this:
-def default(self, o):
- try:
- iterable = iter(o)
- except TypeError:
- pass
- else:
- return list(iterable)
- # Let the base class default method raise the TypeError
- return JSONEncoder.default(self, o)
-
-
-
-
-
-
-
--
-class
pytorch_tabnet.utils.
PredictDataset
(x)[source]
-Bases: torch.utils.data.dataset.Dataset
-Format for numpy array
-
-- Parameters
-X (2D array) – The input matrix
-
-
-
-
-
--
-class
pytorch_tabnet.utils.
TorchDataset
(x, y)[source]
-Bases: torch.utils.data.dataset.Dataset
-Format for numpy array
-
-- Parameters
--
-
-
-
-
-
--
-
pytorch_tabnet.utils.
create_dataloaders
(X_train, y_train, eval_set, weights, batch_size, num_workers, drop_last, pin_memory)[source]
-Create dataloaders with or without subsampling depending on weights and balanced.
-
-- Parameters
-
-X_train (np.ndarray) – Training data
-y_train (np.array) – Mapped Training targets
-eval_set (list of tuple) – List of eval tuple set (X, y)
-weights (either 0, 1, dict or iterable) –
if 0 (default) : no weights will be applied
-if 1 : classification only, will balanced class with inverse frequency
-if dict : keys are corresponding class values are sample weights
-if iterable : list or np array must be of length equal to nb elements
-
-
-
-batch_size (int) – how many samples per batch to load
-num_workers (int) – how many subprocesses to use for data loading. 0 means that the data
-will be loaded in the main process
-drop_last (bool) – set to True to drop the last incomplete batch, if the dataset size is not
-divisible by the batch size. If False and the size of dataset is not
-divisible by the batch size, then the last batch will be smaller
-pin_memory (bool) – Whether to pin GPU memory during training
-
-
-- Returns
-train_dataloader, valid_dataloader – Training and validation dataloaders
-
-- Return type
-torch.DataLoader, torch.DataLoader
-
-
-
-
-
--
-
pytorch_tabnet.utils.
create_explain_matrix
(input_dim, cat_emb_dim, cat_idxs, post_embed_dim)[source]
-This is a computational trick.
-In order to rapidly sum importances from same embeddings
-to the initial index.
-
-- Parameters
-
-input_dim (int) – Initial input dim
-cat_emb_dim (int or list of int) – if int : size of embedding for all categorical feature
-if list of int : size of embedding for each categorical feature
-cat_idxs (list of int) – Initial position of categorical features
-post_embed_dim (int) – Post embedding inputs dimension
-
-
-- Returns
-reducing_matrix – Matrix of dim (post_embed_dim, input_dim) to performe reduce
-
-- Return type
-np.array
-
-
-
-
-
--
-
pytorch_tabnet.utils.
create_sampler
(weights, y_train)[source]
-This creates a sampler from the given weights
-
-- Parameters
-
-weights (either 0, 1, dict or iterable) –
if 0 (default) : no weights will be applied
-if 1 : classification only, will balanced class with inverse frequency
-if dict : keys are corresponding class values are sample weights
-if iterable : list or np array must be of length equal to nb elements
-
-
-
-y_train (np.array) – Training targets
-
-
-
-
-
-
--
-
pytorch_tabnet.utils.
define_device
(device_name)[source]
-Define the device to use during training and inference.
-If auto it will detect automatically whether to use cuda or cpu
-
-- Parameters
-device_name (str) – Either “auto”, “cpu” or “cuda”
-
-- Returns
-Either “cpu” or “cuda”
-
-- Return type
-str
-
-
-
-
-
--
-
pytorch_tabnet.utils.
filter_weights
(weights)[source]
-This function makes sure that weights are in correct format for
-regression and multitask TabNet
-
-- Parameters
-weights (int, dict or list) – Initial weights parameters given by user
-
-- Returns
-None
-
-- Return type
-This function will only throw an error if format is wrong
-
-
-
-
-
--
-
pytorch_tabnet.utils.
validate_eval_set
(eval_set, eval_name, X_train, y_train)[source]
-Check if the shapes of eval_set are compatible with (X_train, y_train).
-
-- Parameters
-
-eval_set (list of tuple) – List of eval tuple set (X, y).
-The last one is used for early stopping
-eval_name (list of str) – List of eval set names.
-X_train (np.ndarray) – Train owned products
-y_train (np.array) – Train targeted products
-
-
-- Returns
--
-
-
-
-
-
-
-
+
pytorch_tabnet.pretraining_utils module
-
@@ -433,8 +239,30 @@
pytorch_tabnet package
-
-
+
+
+pytorch_tabnet.augmentations module
+
+-
+class
pytorch_tabnet.augmentations.
ClassificationSMOTE
(device_name='auto', p=0.8, alpha=0.5, beta=0.5, seed=0)[source]
+Bases: object
+Apply SMOTE for classification tasks.
+This will average a percentage p of the elements in the batch with other elements.
+The target will stay unchanged and keep the value of the most important row in the mix.
+
+
+
+-
+class
pytorch_tabnet.augmentations.
RegressionSMOTE
(device_name='auto', p=0.8, alpha=0.5, beta=0.5, seed=0)[source]
+Bases: object
+Apply SMOTE
+This will average a percentage p of the elements in the batch with other elements.
+The target will be averaged as well (this might work with binary classification
+and certain loss), following a beta distribution.
+
+
+
+
pytorch_tabnet.tab_network module
-
@@ -602,7 +430,7 @@
pytorch_tabnet package[source]
Bases: torch.nn.modules.module.Module
-
@@ -672,7 +500,7 @@
pytorch_tabnet package[source]
Bases: torch.nn.modules.module.Module
-
@@ -702,68 +530,259 @@
pytorch_tabnet package[source]
-
-
-
pytorch_tabnet.multitask module
+
+
+pytorch_tabnet.metrics module
--
-class
pytorch_tabnet.multitask.
TabNetMultiTaskClassifier
(n_d: int = 8, n_a: int = 8, n_steps: int = 3, gamma: float = 1.3, cat_idxs: List[int] = <factory>, cat_dims: List[int] = <factory>, cat_emb_dim: int = 1, n_independent: int = 2, n_shared: int = 2, epsilon: float = 1e-15, momentum: float = 0.02, lambda_sparse: float = 0.001, seed: int = 0, clip_value: int = 1, verbose: int = 1, optimizer_fn: Any = <class 'torch.optim.adam.Adam'>, optimizer_params: Dict = <factory>, scheduler_fn: Any = None, scheduler_params: Dict = <factory>, mask_type: str = 'sparsemax', input_dim: int = None, output_dim: int = None, device_name: str = 'auto')[source]
-Bases: pytorch_tabnet.abstract_model.TabModel
-
--
-
cat_dims
= None
-
+-
+class
pytorch_tabnet.metrics.
AUC
[source]
+Bases: pytorch_tabnet.metrics.Metric
+AUC.
+
-
--
-
cat_idxs
= None
-
+
+-
+class
pytorch_tabnet.metrics.
Accuracy
[source]
+Bases: pytorch_tabnet.metrics.Metric
+Accuracy.
+
-
--
-
compute_loss
(y_pred, y_true)[source]
-Computes the loss according to network output and targets
-
-- Parameters
-
+
+pytorch_tabnet.tab_model module
+
+-
+class
pytorch_tabnet.tab_model.
TabNetClassifier
(n_d: int = 8, n_a: int = 8, n_steps: int = 3, gamma: float = 1.3, cat_idxs: List[int] = <factory>, cat_dims: List[int] = <factory>, cat_emb_dim: int = 1, n_independent: int = 2, n_shared: int = 2, epsilon: float = 1e-15, momentum: float = 0.02, lambda_sparse: float = 0.001, seed: int = 0, clip_value: int = 1, verbose: int = 1, optimizer_fn: Any = <class 'torch.optim.adam.Adam'>, optimizer_params: Dict = <factory>, scheduler_fn: Any = None, scheduler_params: Dict = <factory>, mask_type: str = 'sparsemax', input_dim: int = None, output_dim: int = None, device_name: str = 'auto', n_shared_decoder: int = 1, n_indep_decoder: int = 1)[source]
+Bases: pytorch_tabnet.abstract_model.TabModel
+
+-
+
cat_dims
= None
+
+
+
+-
+
cat_idxs
= None
--
-
predict
(X)[source]
-Make predictions on a batch (valid)
+-
+
compute_loss
(y_pred, y_true)[source]
+Compute the loss.
- Parameters
-X (a :tensor: torch.Tensor) – Input data
+-
- Returns
-results – Predictions of the most probable class
+Loss value
- Return type
-np.array
+float
+
+-
+
optimizer_params
= None
+
+
--
-
predict_proba
(X)[source]
+-
+
predict_func
(outputs)[source]
+
+
+
+-
+
predict_proba
(X)[source]
Make predictions for classification on a batch (valid)
- Parameters
@@ -773,14 +792,14 @@ pytorch_tabnet package
- Return type
-list of np.ndarray
+np.ndarray
--
-
prepare_target
(y)[source]
+-
+
prepare_target
(y)[source]
Prepare target before training.
- Parameters
@@ -796,18 +815,18 @@ pytorch_tabnet package
--
-
scheduler_params
= None
+-
+
scheduler_params
= None
--
-
stack_batches
(list_y_true, list_y_score)[source]
+-
+
stack_batches
(list_y_true, list_y_score)[source]
--
-
update_fit_params
(X_train, y_train, eval_set, weights)[source]
+-
+
update_fit_params
(X_train, y_train, eval_set, weights)[source]
Set attributes relative to fit function.
- Parameters
@@ -822,254 +841,42 @@ pytorch_tabnet package
-
-
-
-
-
pytorch_tabnet.multiclass_utils module
-
-
Multi-class / multi-label utility function
-
--
-
pytorch_tabnet.multiclass_utils.
assert_all_finite
(X, allow_nan=False)[source]
-Throw a ValueError if X contains NaN or infinity.
+
+-
+
weight_updater
(weights)[source]
+Updates weights dictionary according to target_mapper.
- Parameters
--
-
-
-
-
-
--
-
pytorch_tabnet.multiclass_utils.
check_classification_targets
(y)[source]
-Ensure that target y is of a non-regression type.
-
-- Only the following target types (as defined in type_of_target) are allowed:
‘binary’, ‘multiclass’, ‘multiclass-multioutput’,
-‘multilabel-indicator’, ‘multilabel-sequences’
-
-
-
-- Parameters
-y (array-like) –
-
-
-
-
-
--
-
pytorch_tabnet.multiclass_utils.
check_output_dim
(labels, y)[source]
-
-
-
--
-
pytorch_tabnet.multiclass_utils.
check_unique_type
(y)[source]
-
-
-
--
-
pytorch_tabnet.multiclass_utils.
infer_multitask_output
(y_train)[source]
-Infer output_dim from targets
-This is for multiple tasks.
-
-- Parameters
-y_train (np.ndarray) – Training targets
-
-- Returns
--
-
-
-
-
-
-
--
-
pytorch_tabnet.multiclass_utils.
infer_output_dim
(y_train)[source]
-Infer output_dim from targets
-
-- Parameters
-y_train (np.array) – Training targets
-
-- Returns
--
-
-
-
-
-
-
--
-
pytorch_tabnet.multiclass_utils.
is_multilabel
(y)[source]
-Check if y
is in a multilabel format.
-
-- Parameters
-y (numpy array of shape [n_samples]) – Target values.
-
-- Returns
-out – Return True
, if y
is in a multilabel format, else `False
.
-
-- Return type
-bool
-
-
-Examples
->>> import numpy as np
->>> from sklearn.utils.multiclass import is_multilabel
->>> is_multilabel([0, 1, 0, 1])
-False
->>> is_multilabel([[1], [0, 2], []])
-False
->>> is_multilabel(np.array([[1, 0], [0, 0]]))
-True
->>> is_multilabel(np.array([[1], [0], [0]]))
-False
->>> is_multilabel(np.array([[1, 0, 0]]))
-True
-
-
-
-
-
--
-
pytorch_tabnet.multiclass_utils.
type_of_target
(y)[source]
-Determine the type of data indicated by the target.
-Note that this type is the most specific type that can be inferred.
-For example:
-
-
-binary
is more specific but compatible with multiclass
.
-multiclass
of integers is more specific but compatible with
-continuous
.
-multilabel-indicator
is more specific but compatible with
-multiclass-multioutput
.
-
-
-
-- Parameters
-y (array-like) –
+weights (bool or dict) – Given weights for balancing training.
- Returns
-target_type – One of:
-
-’continuous’: y is an array-like of floats that are not all
-integers, and is 1d or a column vector.
-’continuous-multioutput’: y is a 2d array of floats that are
-not all integers, and both dimensions are of size > 1.
-’binary’: y contains <= 2 discrete values and is 1d or a column
-vector.
-’multiclass’: y contains more than two discrete values, is not a
-sequence of sequences, and is 1d or a column vector.
-’multiclass-multioutput’: y is a 2d array that contains more
-than two discrete values, is not a sequence of sequences, and both
-dimensions are of size > 1.
-’multilabel-indicator’: y is a label indicator matrix, an array
-of two dimensions with at least two columns, and at most 2 unique
-values.
-’unknown’: y is array-like but none of the above, such as a 3d
-array, sequence of sequences, or an array of non-sequence objects.
-
-
+Same bool if weights are bool, updated dict otherwise.
- Return type
-string
+bool or dict
-Examples
->>> import numpy as np
->>> type_of_target([0.1, 0.6])
-'continuous'
->>> type_of_target([1, -1, -1, 1])
-'binary'
->>> type_of_target(['a', 'b', 'a'])
-'binary'
->>> type_of_target([1.0, 2.0])
-'binary'
->>> type_of_target([1, 0, 2])
-'multiclass'
->>> type_of_target([1.0, 0.0, 3.0])
-'multiclass'
->>> type_of_target(['a', 'b', 'c'])
-'multiclass'
->>> type_of_target(np.array([[1, 2], [3, 1]]))
-'multiclass-multioutput'
->>> type_of_target([[1, 2]])
-'multiclass-multioutput'
->>> type_of_target(np.array([[1.5, 2.0], [3.0, 1.6]]))
-'continuous-multioutput'
->>> type_of_target(np.array([[0, 1], [1, 1]]))
-'multilabel-indicator'
-
-
-
--
-
pytorch_tabnet.multiclass_utils.
unique_labels
(*ys)[source]
-Extract an ordered array of unique labels
-
-- We don’t allow:
-mix of multilabel and multiclass (single label) targets
-mix of label indicator matrix and anything else,
-because there are no explicit labels)
-mix of label indicator matrices of different sizes
-mix of string and integer labels
-
-
-
-At the moment, we also don’t allow “multiclass-multioutput” input type.
-
-- Parameters
-*ys (array-likes) –
-
-- Returns
-out – An ordered array of unique labels.
-
-- Return type
-numpy array of shape [n_unique_labels]
-
-
-Examples
->>> from sklearn.utils.multiclass import unique_labels
->>> unique_labels([3, 5, 5, 5, 7, 7])
-array([3, 5, 7])
->>> unique_labels([1, 2, 3, 4], [2, 2, 3, 4])
-array([1, 2, 3, 4])
->>> unique_labels([1, 2, 10], [5, 11])
-array([ 1, 2, 5, 10, 11])
-
-
-
-
-
-
pytorch_tabnet.tab_model module
--
-class
pytorch_tabnet.tab_model.
TabNetClassifier
(n_d: int = 8, n_a: int = 8, n_steps: int = 3, gamma: float = 1.3, cat_idxs: List[int] = <factory>, cat_dims: List[int] = <factory>, cat_emb_dim: int = 1, n_independent: int = 2, n_shared: int = 2, epsilon: float = 1e-15, momentum: float = 0.02, lambda_sparse: float = 0.001, seed: int = 0, clip_value: int = 1, verbose: int = 1, optimizer_fn: Any = <class 'torch.optim.adam.Adam'>, optimizer_params: Dict = <factory>, scheduler_fn: Any = None, scheduler_params: Dict = <factory>, mask_type: str = 'sparsemax', input_dim: int = None, output_dim: int = None, device_name: str = 'auto')[source]
+-
+class
pytorch_tabnet.tab_model.
TabNetRegressor
(n_d: int = 8, n_a: int = 8, n_steps: int = 3, gamma: float = 1.3, cat_idxs: List[int] = <factory>, cat_dims: List[int] = <factory>, cat_emb_dim: int = 1, n_independent: int = 2, n_shared: int = 2, epsilon: float = 1e-15, momentum: float = 0.02, lambda_sparse: float = 0.001, seed: int = 0, clip_value: int = 1, verbose: int = 1, optimizer_fn: Any = <class 'torch.optim.adam.Adam'>, optimizer_params: Dict = <factory>, scheduler_fn: Any = None, scheduler_params: Dict = <factory>, mask_type: str = 'sparsemax', input_dim: int = None, output_dim: int = None, device_name: str = 'auto', n_shared_decoder: int = 1, n_indep_decoder: int = 1)[source]
Bases: pytorch_tabnet.abstract_model.TabModel
--
-
cat_dims
= None
+-
+
cat_dims
= None
--
-
cat_idxs
= None
+-
+
cat_idxs
= None
--
-
compute_loss
(y_pred, y_true)[source]
+-
+
compute_loss
(y_pred, y_true)[source]
Compute the loss.
- Parameters
@@ -1088,35 +895,18 @@ Multi-class / multi-label utility function
--
-
predict_func
(outputs)[source]
+-
+
predict_func
(outputs)[source]
--
-
predict_proba
(X)[source]
-Make predictions for classification on a batch (valid)
-
-- Parameters
-X (a :tensor: torch.Tensor) – Input data
-
-- Returns
-res
-
-- Return type
-np.ndarray
-
-
-
-
-
--
-
prepare_target
(y)[source]
+-
+
prepare_target
(y)[source]
Prepare target before training.
- Parameters
@@ -1132,19 +922,19 @@ Multi-class / multi-label utility function
--
-
stack_batches
(list_y_true, list_y_score)[source]
+-
+
stack_batches
(list_y_true, list_y_score)[source]
--
-
update_fit_params
(X_train, y_train, eval_set, weights)[source]
-Set attributes relative to fit function.
+-
+
update_fit_params
(X_train, y_train, eval_set, weights)[source]
+Set attributes relative to fit function.
- Parameters
@@ -1158,404 +948,190 @@ Multi-class / multi-label utility function
-
+
+
+pytorch_tabnet.sparsemax module
--
-class
pytorch_tabnet.tab_model.
TabNetRegressor
(n_d: int = 8, n_a: int = 8, n_steps: int = 3, gamma: float = 1.3, cat_idxs: List[int] = <factory>, cat_dims: List[int] = <factory>, cat_emb_dim: int = 1, n_independent: int = 2, n_shared: int = 2, epsilon: float = 1e-15, momentum: float = 0.02, lambda_sparse: float = 0.001, seed: int = 0, clip_value: int = 1, verbose: int = 1, optimizer_fn: Any = <class 'torch.optim.adam.Adam'>, optimizer_params: Dict = <factory>, scheduler_fn: Any = None, scheduler_params: Dict = <factory>, mask_type: str = 'sparsemax', input_dim: int = None, output_dim: int = None, device_name: str = 'auto')[source]
-Bases: pytorch_tabnet.abstract_model.TabModel
-
--
-
cat_dims
= None
-
-
-
--
-
cat_idxs
= None
-
-
+-
+class
pytorch_tabnet.sparsemax.
Entmax15
(dim=-1)[source]
+Bases: torch.nn.modules.module.Module
--
-
compute_loss
(y_pred, y_true)[source]
-Compute the loss.
-
-- Parameters
--
-
-- Returns
-Loss value
-
-- Return type
-float
-
-
+-
+
forward
(input)[source]
+Defines the computation performed at every call.
+Should be overridden by all subclasses.
+
+
Note
+
Although the recipe for forward pass needs to be defined within
+this function, one should call the Module
instance afterwards
+instead of this since the former takes care of running the
+registered hooks while the latter silently ignores them.
+
-
--
-
optimizer_params
= None
-
+
+
+-
+class
pytorch_tabnet.sparsemax.
Entmax15Function
[source]
+Bases: torch.autograd.function.Function
+An implementation of exact Entmax with alpha=1.5 (B. Peters, V. Niculae, A. Martins). See
+:cite:`https://arxiv.org/abs/1905.05702 for detailed description.
+Source: https://github.com/deep-spin/entmax
--
-
predict_func
(outputs)[source]
-
+-
+static
backward
(ctx, grad_output)[source]
+Defines a formula for differentiating the operation.
+This function is to be overridden by all subclasses.
+It must accept a context ctx
as the first argument, followed by
+as many outputs did forward()
return, and it should return as many
+tensors, as there were inputs to forward()
. Each argument is the
+gradient w.r.t the given output, and each returned value should be the
+gradient w.r.t. the corresponding input.
+The context can be used to retrieve tensors saved during the forward
+pass. It also has an attribute ctx.needs_input_grad
as a tuple
+of booleans representing whether each input needs gradient. E.g.,
+backward()
will have ctx.needs_input_grad[0] = True
if the
+first input to forward()
needs gradient computated w.r.t. the
+output.
+
--
-
prepare_target
(y)[source]
-Prepare target before training.
-
-- Parameters
-y (a :tensor: torch.Tensor) – Target matrix.
-
-- Returns
-Converted target matrix.
-
-- Return type
-torch.Tensor
-
-
+-
+static
forward
(ctx, input, dim=-1)[source]
+Performs the operation.
+This function is to be overridden by all subclasses.
+It must accept a context ctx as the first argument, followed by any
+number of arguments (tensors or other types).
+The context can be used to store tensors that can be then retrieved
+during the backward pass.
-
--
-
scheduler_params
= None
-
+
+
+-
+class
pytorch_tabnet.sparsemax.
Entmoid15
[source]
+Bases: torch.autograd.function.Function
+A highly optimized equivalent of lambda x: Entmax15([x, 0])
--
-
stack_batches
(list_y_true, list_y_score)[source]
-
+-
+static
backward
(ctx, grad_output)[source]
+Defines a formula for differentiating the operation.
+This function is to be overridden by all subclasses.
+It must accept a context ctx
as the first argument, followed by
+as many outputs did forward()
return, and it should return as many
+tensors, as there were inputs to forward()
. Each argument is the
+gradient w.r.t the given output, and each returned value should be the
+gradient w.r.t. the corresponding input.
+The context can be used to retrieve tensors saved during the forward
+pass. It also has an attribute ctx.needs_input_grad
as a tuple
+of booleans representing whether each input needs gradient. E.g.,
+backward()
will have ctx.needs_input_grad[0] = True
if the
+first input to forward()
needs gradient computated w.r.t. the
+output.
+
--
-
update_fit_params
(X_train, y_train, eval_set, weights)[source]
-Set attributes relative to fit function.
-
-- Parameters
-
-X_train (np.ndarray) – Train set
-y_train (np.array) – Train targets
-eval_set (list of tuple) – List of eval tuple set (X, y).
-weights (bool or dictionnary) – 0 for no balancing
-1 for automated balancing
-
-
-
+-
+static
forward
(ctx, input)[source]
+Performs the operation.
+This function is to be overridden by all subclasses.
+It must accept a context ctx as the first argument, followed by any
+number of arguments (tensors or other types).
+The context can be used to store tensors that can be then retrieved
+during the backward pass.
-
-
-
pytorch_tabnet.abstract_model module
--
-class
pytorch_tabnet.abstract_model.
TabModel
(n_d: int = 8, n_a: int = 8, n_steps: int = 3, gamma: float = 1.3, cat_idxs: List[int] = <factory>, cat_dims: List[int] = <factory>, cat_emb_dim: int = 1, n_independent: int = 2, n_shared: int = 2, epsilon: float = 1e-15, momentum: float = 0.02, lambda_sparse: float = 0.001, seed: int = 0, clip_value: int = 1, verbose: int = 1, optimizer_fn: Any = <class 'torch.optim.adam.Adam'>, optimizer_params: Dict = <factory>, scheduler_fn: Any = None, scheduler_params: Dict = <factory>, mask_type: str = 'sparsemax', input_dim: int = None, output_dim: int = None, device_name: str = 'auto')[source]
-Bases: sklearn.base.BaseEstimator
-Class for TabNet model.
-
--
-
cat_dims
: List[int] = None
-
-
-
--
-
cat_emb_dim
: int = 1
-
+-
+class
pytorch_tabnet.sparsemax.
Sparsemax
(dim=-1)[source]
+Bases: torch.nn.modules.module.Module
+
+-
+
forward
(input)[source]
+Defines the computation performed at every call.
+Should be overridden by all subclasses.
+
+
Note
+
Although the recipe for forward pass needs to be defined within
+this function, one should call the Module
instance afterwards
+instead of this since the former takes care of running the
+registered hooks while the latter silently ignores them.
+
+
-
--
-
cat_idxs
: List[int] = None
-
+
-
--
-
clip_value
: int = 1
-
+
+-
+class
pytorch_tabnet.sparsemax.
SparsemaxFunction
[source]
+Bases: torch.autograd.function.Function
+An implementation of sparsemax (Martins & Astudillo, 2016). See
+:cite:`DBLP:journals/corr/MartinsA16` for detailed description.
+By Ben Peters and Vlad Niculae
+
+-
+static
backward
(ctx, grad_output)[source]
+Defines a formula for differentiating the operation.
+This function is to be overridden by all subclasses.
+It must accept a context ctx
as the first argument, followed by
+as many outputs did forward()
return, and it should return as many
+tensors, as there were inputs to forward()
. Each argument is the
+gradient w.r.t the given output, and each returned value should be the
+gradient w.r.t. the corresponding input.
+The context can be used to retrieve tensors saved during the forward
+pass. It also has an attribute ctx.needs_input_grad
as a tuple
+of booleans representing whether each input needs gradient. E.g.,
+backward()
will have ctx.needs_input_grad[0] = True
if the
+first input to forward()
needs gradient computated w.r.t. the
+output.
+
--
-abstract
compute_loss
(y_score, y_true)[source]
-Compute the loss.
+-
+static
forward
(ctx, input, dim=-1)[source]
+sparsemax: normalizing sparse transform (a la softmax)
- Parameters
-y_score (a :tensor: torch.Tensor) – Score matrix
-y_true (a :tensor: torch.Tensor) – Target matrix
+ctx (torch.autograd.function._ContextMethodMixin) –
+input (torch.Tensor) – any shape
+dim (int) – dimension along which to apply sparsemax
- Returns
-Loss value
+output – same shape as input
- Return type
-float
+torch.Tensor
-
--
-
device_name
: str = 'auto'
+
+
+
+-
+
pytorch_tabnet.sparsemax.
entmax15
()
-
--
-
epsilon
: float = 1e-15
-
-
-
--
-
explain
(X)[source]
-Return local explanation
-
-- Parameters
-X (tensor: torch.Tensor) – Input data
-
-- Returns
-
-M_explain (matrix) – Importance per sample, per columns.
-masks (matrix) – Sparse matrix showing attention masks used by network.
-
-
-
-
-
-
-
--
-
fit
(X_train, y_train, eval_set=None, eval_name=None, eval_metric=None, loss_fn=None, weights=0, max_epochs=100, patience=10, batch_size=1024, virtual_batch_size=128, num_workers=0, drop_last=False, callbacks=None, pin_memory=True, from_unsupervised=None)[source]
-Train a neural network stored in self.network
-Using train_dataloader for training data and
-valid_dataloader for validation.
-
-- Parameters
-
-X_train (np.ndarray) – Train set
-y_train (np.array) – Train targets
-eval_set (list of tuple) – List of eval tuple set (X, y).
-The last one is used for early stopping
-eval_name (list of str) – List of eval set names.
-eval_metric (list of str) – List of evaluation metrics.
-The last metric is used for early stopping.
-loss_fn (callable or None) – a PyTorch loss function
-weights (bool or dictionnary) – 0 for no balancing
-1 for automated balancing
-dict for custom weights per class
-max_epochs (int) – Maximum number of epochs during training
-patience (int) – Number of consecutive non improving epoch before early stopping
-batch_size (int) – Training batch size
-virtual_batch_size (int) – Batch size for Ghost Batch Normalization (virtual_batch_size < batch_size)
-num_workers (int) – Number of workers used in torch.utils.data.DataLoader
-drop_last (bool) – Whether to drop last batch during training
-callbacks (list of callback function) – List of custom callbacks
-pin_memory (bool) – Whether to set pin_memory to True or False during training
-from_unsupervised (unsupervised trained model) – Use a previously self supervised model as starting weights
-
-
-
-
-
-
--
-
gamma
: float = 1.3
-
-
-
--
-
input_dim
: int = None
-
-
-
--
-
lambda_sparse
: float = 0.001
-
-
-
--
-
load_class_attrs
(class_attrs)[source]
-
-
-
--
-
load_model
(filepath)[source]
-Load TabNet model.
-
-- Parameters
-filepath (str) – Path of the model.
-
-
-
-
-
--
-
load_weights_from_unsupervised
(unsupervised_model)[source]
-
-
-
--
-
mask_type
: str = 'sparsemax'
-
-
-
--
-
momentum
: float = 0.02
-
-
-
--
-
n_a
: int = 8
-
-
-
--
-
n_d
: int = 8
-
-
-
--
-
n_independent
: int = 2
-
-
-
--
-
n_shared
: int = 2
-
-
-
--
-
n_steps
: int = 3
-
-
-
--
-
optimizer_fn
-alias of torch.optim.adam.Adam
-
-
-
--
-
optimizer_params
: Dict = None
-
-
-
--
-
output_dim
: int = None
-
-
-
--
-
predict
(X)[source]
-Make predictions on a batch (valid)
-
-- Parameters
-X (a :tensor: torch.Tensor) – Input data
-
-- Returns
-predictions – Predictions of the regression problem
-
-- Return type
-np.array
-
-
-
-
-
--
-abstract
prepare_target
(y)[source]
-Prepare target before training.
-
-- Parameters
-y (a :tensor: torch.Tensor) – Target matrix.
-
-- Returns
-Converted target matrix.
-
-- Return type
-torch.Tensor
-
-
-
-
-
--
-
save_model
(path)[source]
-Saving TabNet model in two distinct files.
-
-- Parameters
-path (str) – Path of the model.
-
-- Returns
-input filepath with “.zip” appended
-
-- Return type
-str
-
-
-
-
-
--
-
scheduler_fn
: Any = None
-
-
-
--
-
scheduler_params
: Dict = None
-
-
-
--
-
seed
: int = 0
+
+-
+
pytorch_tabnet.sparsemax.
entmoid15
()
-
--
-abstract
update_fit_params
(X_train, y_train, eval_set, weights)[source]
-Set attributes relative to fit function.
-
-- Parameters
-
-X_train (np.ndarray) – Train set
-y_train (np.array) – Train targets
-eval_set (list of tuple) – List of eval tuple set (X, y).
-weights (bool or dictionnary) – 0 for no balancing
-1 for automated balancing
-
-
-
-
-
-
--
-
verbose
: int = 1
+
+-
+
pytorch_tabnet.sparsemax.
sparsemax
()
-
-
-
-
+
+
pytorch_tabnet.callbacks module
-
@@ -1812,31 +1388,42 @@
Multi-class / multi-label utility function
+
+pytorch_tabnet.abstract_model module
--
-class
pytorch_tabnet.pretraining.
TabNetPretrainer
(n_d: int = 8, n_a: int = 8, n_steps: int = 3, gamma: float = 1.3, cat_idxs: List[int] = <factory>, cat_dims: List[int] = <factory>, cat_emb_dim: int = 1, n_independent: int = 2, n_shared: int = 2, epsilon: float = 1e-15, momentum: float = 0.02, lambda_sparse: float = 0.001, seed: int = 0, clip_value: int = 1, verbose: int = 1, optimizer_fn: Any = <class 'torch.optim.adam.Adam'>, optimizer_params: Dict = <factory>, scheduler_fn: Any = None, scheduler_params: Dict = <factory>, mask_type: str = 'sparsemax', input_dim: int = None, output_dim: int = None, device_name: str = 'auto')[source]
-Bases: pytorch_tabnet.abstract_model.TabModel
+-
+class
pytorch_tabnet.abstract_model.
TabModel
(n_d: int = 8, n_a: int = 8, n_steps: int = 3, gamma: float = 1.3, cat_idxs: List[int] = <factory>, cat_dims: List[int] = <factory>, cat_emb_dim: int = 1, n_independent: int = 2, n_shared: int = 2, epsilon: float = 1e-15, momentum: float = 0.02, lambda_sparse: float = 0.001, seed: int = 0, clip_value: int = 1, verbose: int = 1, optimizer_fn: Any = <class 'torch.optim.adam.Adam'>, optimizer_params: Dict = <factory>, scheduler_fn: Any = None, scheduler_params: Dict = <factory>, mask_type: str = 'sparsemax', input_dim: int = None, output_dim: int = None, device_name: str = 'auto', n_shared_decoder: int = 1, n_indep_decoder: int = 1)[source]
+Bases: sklearn.base.BaseEstimator
+Class for TabNet model.
--
-
cat_dims
= None
+-
+
cat_dims
: List[int] = None
--
-
cat_idxs
= None
+-
+
cat_emb_dim
: int = 1
-
--
-
compute_loss
(output, embedded_x, obf_vars)[source]
-Compute the loss.
-
-- Parameters
-
-
-
pytorch_tabnet.sparsemax module
+
+
+pytorch_tabnet.pretraining module
--
-class
pytorch_tabnet.sparsemax.
Entmax15
(dim=-1)[source]
-Bases: torch.nn.modules.module.Module
-
--
-
forward
(input)[source]
-Defines the computation performed at every call.
-Should be overridden by all subclasses.
-
-
Note
-
Although the recipe for forward pass needs to be defined within
-this function, one should call the Module
instance afterwards
-instead of this since the former takes care of running the
-registered hooks while the latter silently ignores them.
-
-
+-
+class
pytorch_tabnet.pretraining.
TabNetPretrainer
(n_d: int = 8, n_a: int = 8, n_steps: int = 3, gamma: float = 1.3, cat_idxs: List[int] = <factory>, cat_dims: List[int] = <factory>, cat_emb_dim: int = 1, n_independent: int = 2, n_shared: int = 2, epsilon: float = 1e-15, momentum: float = 0.02, lambda_sparse: float = 0.001, seed: int = 0, clip_value: int = 1, verbose: int = 1, optimizer_fn: Any = <class 'torch.optim.adam.Adam'>, optimizer_params: Dict = <factory>, scheduler_fn: Any = None, scheduler_params: Dict = <factory>, mask_type: str = 'sparsemax', input_dim: int = None, output_dim: int = None, device_name: str = 'auto', n_shared_decoder: int = 1, n_indep_decoder: int = 1)[source]
+Bases: pytorch_tabnet.abstract_model.TabModel
+
+-
+
cat_dims
= None
+
-
+
+-
+
cat_idxs
= None
+
-
--
-class
pytorch_tabnet.sparsemax.
Entmax15Function
[source]
-Bases: torch.autograd.function.Function
-An implementation of exact Entmax with alpha=1.5 (B. Peters, V. Niculae, A. Martins). See
-:cite:`https://arxiv.org/abs/1905.05702 for detailed description.
-Source: https://github.com/deep-spin/entmax
--
-static
backward
(ctx, grad_output)[source]
-Defines a formula for differentiating the operation.
-This function is to be overridden by all subclasses.
-It must accept a context ctx
as the first argument, followed by
-as many outputs did forward()
return, and it should return as many
-tensors, as there were inputs to forward()
. Each argument is the
-gradient w.r.t the given output, and each returned value should be the
-gradient w.r.t. the corresponding input.
-The context can be used to retrieve tensors saved during the forward
-pass. It also has an attribute ctx.needs_input_grad
as a tuple
-of booleans representing whether each input needs gradient. E.g.,
-backward()
will have ctx.needs_input_grad[0] = True
if the
-first input to forward()
needs gradient computated w.r.t. the
-output.
-
+-
+
compute_loss
(output, embedded_x, obf_vars)[source]
+Compute the loss.
+
+- Parameters
+-
+
+- Returns
+Loss value
+
+- Return type
+float
+
+
+
--
-static
forward
(ctx, input, dim=-1)[source]
-Performs the operation.
-This function is to be overridden by all subclasses.
-It must accept a context ctx as the first argument, followed by any
-number of arguments (tensors or other types).
-The context can be used to store tensors that can be then retrieved
-during the backward pass.
+-
+
fit
(X_train, eval_set=None, eval_name=None, loss_fn=None, pretraining_ratio=0.5, weights=0, max_epochs=100, patience=10, batch_size=1024, virtual_batch_size=128, num_workers=0, drop_last=True, callbacks=None, pin_memory=True, warm_start=False)[source]
+Train a neural network stored in self.network
+Using train_dataloader for training data and
+valid_dataloader for validation.
+
+- Parameters
+
+X_train (np.ndarray) – Train set to reconstruct in self supervision
+eval_set (list of np.array) – List of evaluation set
+The last one is used for early stopping
+eval_name (list of str) – List of eval set names.
+eval_metric (list of str) – List of evaluation metrics.
+The last metric is used for early stopping.
+loss_fn (callable or None) – a PyTorch loss function
+should be left to None for self supervised and non experts
+pretraining_ratio (float) – Between 0 and 1, percentage of feature to mask for reconstruction
+weights (np.array) – Sampling weights for each example.
+max_epochs (int) – Maximum number of epochs during training
+patience (int) – Number of consecutive non improving epoch before early stopping
+batch_size (int) – Training batch size
+virtual_batch_size (int) – Batch size for Ghost Batch Normalization (virtual_batch_size < batch_size)
+num_workers (int) – Number of workers used in torch.utils.data.DataLoader
+drop_last (bool) – Whether to drop last batch during training
+callbacks (list of callback function) – List of custom callbacks
+pin_memory (bool) – Whether to set pin_memory to True or False during training
+
+
+
+
+-
+
optimizer_params
= None
+
+
+
+-
+
predict
(X)[source]
+Make predictions on a batch (valid)
+
+- Parameters
+X (a :tensor: torch.Tensor) – Input data
+
+- Returns
+predictions – Predictions of the regression problem
+
+- Return type
+np.array
+
+
-
--
-class
pytorch_tabnet.sparsemax.
Entmoid15
[source]
-Bases: torch.autograd.function.Function
-A highly optimized equivalent of lambda x: Entmax15([x, 0])
--
-static
backward
(ctx, grad_output)[source]
-Defines a formula for differentiating the operation.
-This function is to be overridden by all subclasses.
-It must accept a context ctx
as the first argument, followed by
-as many outputs did forward()
return, and it should return as many
-tensors, as there were inputs to forward()
. Each argument is the
-gradient w.r.t the given output, and each returned value should be the
-gradient w.r.t. the corresponding input.
-The context can be used to retrieve tensors saved during the forward
-pass. It also has an attribute ctx.needs_input_grad
as a tuple
-of booleans representing whether each input needs gradient. E.g.,
-backward()
will have ctx.needs_input_grad[0] = True
if the
-first input to forward()
needs gradient computated w.r.t. the
-output.
+-
+
prepare_target
(y)[source]
+Prepare target before training.
+
+- Parameters
+y (a :tensor: torch.Tensor) – Target matrix.
+
+- Returns
+Converted target matrix.
+
+- Return type
+torch.Tensor
+
+
+
+-
+
scheduler_params
= None
+
+
--
-static
forward
(ctx, input)[source]
-Performs the operation.
-This function is to be overridden by all subclasses.
-It must accept a context ctx as the first argument, followed by any
-number of arguments (tensors or other types).
-The context can be used to store tensors that can be then retrieved
-during the backward pass.
+-
+
stack_batches
(list_output, list_embedded_x, list_obfuscation)[source]
+
+
+
+-
+
update_fit_params
(weights)[source]
+Set attributes relative to fit function.
+
+- Parameters
+
+X_train (np.ndarray) – Train set
+y_train (np.array) – Train targets
+eval_set (list of tuple) – List of eval tuple set (X, y).
+weights (bool or dictionnary) – 0 for no balancing
+1 for automated balancing
+
+
+
+
+
+
+
+
+
+pytorch_tabnet.utils module
+
+-
+class
pytorch_tabnet.utils.
ComplexEncoder
(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]
+Bases: json.encoder.JSONEncoder
+
+-
+
default
(obj)[source]
+Implement this method in a subclass such that it returns
+a serializable object for o
, or calls the base implementation
+(to raise a TypeError
).
+For example, to support arbitrary iterators, you could
+implement default like this:
+def default(self, o):
+ try:
+ iterable = iter(o)
+ except TypeError:
+ pass
+ else:
+ return list(iterable)
+ # Let the base class default method raise the TypeError
+ return JSONEncoder.default(self, o)
+
+
+
+
+
+
+
+-
+class
pytorch_tabnet.utils.
PredictDataset
(x)[source]
+Bases: torch.utils.data.dataset.Dataset
+Format for numpy array
+
+- Parameters
+X (2D array) – The input matrix
+
+
+
+
+
+-
+class
pytorch_tabnet.utils.
TorchDataset
(x, y)[source]
+Bases: torch.utils.data.dataset.Dataset
+Format for numpy array
+
+- Parameters
+-
+
+
+
+
+
+-
+
pytorch_tabnet.utils.
check_input
(X)[source]
+Raise a clear error if X is a pandas dataframe
+and check array according to scikit rules
+
+
+
+-
+
pytorch_tabnet.utils.
check_warm_start
(warm_start, from_unsupervised)[source]
+Gives a warning about ambiguous usage of the two parameters.
+
+
+
+-
+
pytorch_tabnet.utils.
create_dataloaders
(X_train, y_train, eval_set, weights, batch_size, num_workers, drop_last, pin_memory)[source]
+Create dataloaders with or without subsampling depending on weights and balanced.
+
+- Parameters
+
+X_train (np.ndarray) – Training data
+y_train (np.array) – Mapped Training targets
+eval_set (list of tuple) – List of eval tuple set (X, y)
+weights (either 0, 1, dict or iterable) –
if 0 (default) : no weights will be applied
+if 1 : classification only, will balanced class with inverse frequency
+if dict : keys are corresponding class values are sample weights
+if iterable : list or np array must be of length equal to nb elements
+
+
+
+batch_size (int) – how many samples per batch to load
+num_workers (int) – how many subprocesses to use for data loading. 0 means that the data
+will be loaded in the main process
+drop_last (bool) – set to True to drop the last incomplete batch, if the dataset size is not
+divisible by the batch size. If False and the size of dataset is not
+divisible by the batch size, then the last batch will be smaller
+pin_memory (bool) – Whether to pin GPU memory during training
+
+
+- Returns
+train_dataloader, valid_dataloader – Training and validation dataloaders
+
+- Return type
+torch.DataLoader, torch.DataLoader
+
+
+
+
+
+-
+
pytorch_tabnet.utils.
create_explain_matrix
(input_dim, cat_emb_dim, cat_idxs, post_embed_dim)[source]
+This is a computational trick.
+In order to rapidly sum importances from same embeddings
+to the initial index.
+
+- Parameters
+
+input_dim (int) – Initial input dim
+cat_emb_dim (int or list of int) – if int : size of embedding for all categorical feature
+if list of int : size of embedding for each categorical feature
+cat_idxs (list of int) – Initial position of categorical features
+post_embed_dim (int) – Post embedding inputs dimension
+
+
+- Returns
+reducing_matrix – Matrix of dim (post_embed_dim, input_dim) to performe reduce
+
+- Return type
+np.array
+
+
+
+
+
+-
+
pytorch_tabnet.utils.
create_sampler
(weights, y_train)[source]
+This creates a sampler from the given weights
+
+- Parameters
+
+weights (either 0, 1, dict or iterable) –
if 0 (default) : no weights will be applied
+if 1 : classification only, will balanced class with inverse frequency
+if dict : keys are corresponding class values are sample weights
+if iterable : list or np array must be of length equal to nb elements
+
+
+
+y_train (np.array) – Training targets
+
+
+
+
+-
+
pytorch_tabnet.utils.
define_device
(device_name)[source]
+Define the device to use during training and inference.
+If auto it will detect automatically whether to use cuda or cpu
+
+- Parameters
+device_name (str) – Either “auto”, “cpu” or “cuda”
+
+- Returns
+Either “cpu” or “cuda”
+
+- Return type
+str
+
+
-
--
-class
pytorch_tabnet.sparsemax.
Sparsemax
(dim=-1)[source]
-Bases: torch.nn.modules.module.Module
-
--
-
forward
(input)[source]
-Defines the computation performed at every call.
-Should be overridden by all subclasses.
-
-
Note
-
Although the recipe for forward pass needs to be defined within
-this function, one should call the Module
instance afterwards
-instead of this since the former takes care of running the
-registered hooks while the latter silently ignores them.
-
+
+-
+
pytorch_tabnet.utils.
filter_weights
(weights)[source]
+This function makes sure that weights are in correct format for
+regression and multitask TabNet
+
+- Parameters
+weights (int, dict or list) – Initial weights parameters given by user
+
+- Returns
+None
+
+- Return type
+This function will only throw an error if format is wrong
+
+
+
+-
+
pytorch_tabnet.utils.
validate_eval_set
(eval_set, eval_name, X_train, y_train)[source]
+Check if the shapes of eval_set are compatible with (X_train, y_train).
+
+- Parameters
+
+eval_set (list of tuple) – List of eval tuple set (X, y).
+The last one is used for early stopping
+eval_name (list of str) – List of eval set names.
+X_train (np.ndarray) – Train owned products
+y_train (np.array) – Train targeted products
+
+
+- Returns
+-
+
+
+
+
+
+pytorch_tabnet.multitask module
--
-class
pytorch_tabnet.sparsemax.
SparsemaxFunction
[source]
-Bases: torch.autograd.function.Function
-An implementation of sparsemax (Martins & Astudillo, 2016). See
-:cite:`DBLP:journals/corr/MartinsA16` for detailed description.
-By Ben Peters and Vlad Niculae
-
--
-static
backward
(ctx, grad_output)[source]
-Defines a formula for differentiating the operation.
-This function is to be overridden by all subclasses.
-It must accept a context ctx
as the first argument, followed by
-as many outputs did forward()
return, and it should return as many
-tensors, as there were inputs to forward()
. Each argument is the
-gradient w.r.t the given output, and each returned value should be the
-gradient w.r.t. the corresponding input.
-The context can be used to retrieve tensors saved during the forward
-pass. It also has an attribute ctx.needs_input_grad
as a tuple
-of booleans representing whether each input needs gradient. E.g.,
-backward()
will have ctx.needs_input_grad[0] = True
if the
-first input to forward()
needs gradient computated w.r.t. the
-output.
-
+-
+class
pytorch_tabnet.multitask.
TabNetMultiTaskClassifier
(n_d: int = 8, n_a: int = 8, n_steps: int = 3, gamma: float = 1.3, cat_idxs: List[int] = <factory>, cat_dims: List[int] = <factory>, cat_emb_dim: int = 1, n_independent: int = 2, n_shared: int = 2, epsilon: float = 1e-15, momentum: float = 0.02, lambda_sparse: float = 0.001, seed: int = 0, clip_value: int = 1, verbose: int = 1, optimizer_fn: Any = <class 'torch.optim.adam.Adam'>, optimizer_params: Dict = <factory>, scheduler_fn: Any = None, scheduler_params: Dict = <factory>, mask_type: str = 'sparsemax', input_dim: int = None, output_dim: int = None, device_name: str = 'auto', n_shared_decoder: int = 1, n_indep_decoder: int = 1)[source]
+Bases: pytorch_tabnet.abstract_model.TabModel
+
+-
+
cat_dims
= None
+
+
+
+-
+
cat_idxs
= None
+
--
-static
forward
(ctx, input, dim=-1)[source]
-sparsemax: normalizing sparse transform (a la softmax)
+-
+
compute_loss
(y_pred, y_true)[source]
+Computes the loss according to network output and targets
- Parameters
-ctx (torch.autograd.function._ContextMethodMixin) –
-input (torch.Tensor) – any shape
-dim (int) – dimension along which to apply sparsemax
+y_pred (list of tensors) – Output of network
+y_true (LongTensor) – Targets label encoded
- Returns
-output – same shape as input
+loss – output of loss function(s)
- Return type
torch.Tensor
@@ -2112,216 +2075,319 @@ Multi-class / multi-label utility function
-
-
--
-
pytorch_tabnet.sparsemax.
entmoid15
()
-
-
-
--
-
pytorch_tabnet.sparsemax.
sparsemax
()
+
+-
+
optimizer_params
= None
-
-
-
pytorch_tabnet.metrics module
-
--
-class
pytorch_tabnet.metrics.
AUC
[source]
-Bases: pytorch_tabnet.metrics.Metric
-AUC.
+
+-
+
predict
(X)[source]
+Make predictions on a batch (valid)
+
+- Parameters
+X (a :tensor: torch.Tensor) – Input data
+
+- Returns
+results – Predictions of the most probable class
+
+- Return type
+np.array
+
+
-
--
-class
pytorch_tabnet.metrics.
Accuracy
[source]
-Bases: pytorch_tabnet.metrics.Metric
-Accuracy.
+
+-
+
predict_proba
(X)[source]
+Make predictions for classification on a batch (valid)
+
+- Parameters
+X (a :tensor: torch.Tensor) – Input data
+
+- Returns
+res
+
+- Return type
+list of np.ndarray
+
+
-
--
-class
pytorch_tabnet.metrics.
BalancedAccuracy
[source]
-Bases: pytorch_tabnet.metrics.Metric
-Balanced Accuracy.
+
+-
+
prepare_target
(y)[source]
+Prepare target before training.
+
+- Parameters
+y (a :tensor: torch.Tensor) – Target matrix.
+
+- Returns
+Converted target matrix.
+
+- Return type
+torch.Tensor
+
+
-
--
-class
pytorch_tabnet.metrics.
LogLoss
[source]
-Bases: pytorch_tabnet.metrics.Metric
-LogLoss.
-
+
+-
+
scheduler_params
= None
+
-
--
-class
pytorch_tabnet.metrics.
MAE
[source]
-Bases: pytorch_tabnet.metrics.Metric
-Mean Absolute Error.
+
+-
+
stack_batches
(list_y_true, list_y_score)[source]
+
+
+
+-
+
update_fit_params
(X_train, y_train, eval_set, weights)[source]
+Set attributes relative to fit function.
+
+- Parameters
+
+X_train (np.ndarray) – Train set
+y_train (np.array) – Train targets
+eval_set (list of tuple) – List of eval tuple set (X, y).
+weights (bool or dictionnary) – 0 for no balancing
+1 for automated balancing
+
+
+
-
--
-class
pytorch_tabnet.metrics.
MSE
[source]
-Bases: pytorch_tabnet.metrics.Metric
-Mean Squared Error.
-
--
-class
pytorch_tabnet.metrics.
Metric
[source]
-Bases: object
-
--
-classmethod
get_metrics_by_names
(names)[source]
-Get list of metric classes.
+
+
+pytorch_tabnet.multiclass_utils module
+
+Multi-class / multi-label utility function
+
+-
+
pytorch_tabnet.multiclass_utils.
assert_all_finite
(X, allow_nan=False)[source]
+Throw a ValueError if X contains NaN or infinity.
- Parameters
-cls (Metric) – Metric class.
-names (list) – List of metric names.
+X (array or sparse matrix) –
+allow_nan (bool) –
-- Returns
-metrics – List of metric classes.
-
-- Return type
-list
-
-
-
-
--
-class
pytorch_tabnet.metrics.
MetricContainer
(metric_names: List[str], prefix: str = '')[source]
-Bases: object
-Container holding a list of metrics.
+
+-
+
pytorch_tabnet.multiclass_utils.
check_classification_targets
(y)[source]
+Ensure that target y is of a non-regression type.
+
+- Only the following target types (as defined in type_of_target) are allowed:
‘binary’, ‘multiclass’, ‘multiclass-multioutput’,
+‘multilabel-indicator’, ‘multilabel-sequences’
+
+
- Parameters
--
+
y (array-like) –
-
--
-
metric_names
: List[str] = None
-
+
-
--
-
prefix
: str = ''
+
+-
+
pytorch_tabnet.multiclass_utils.
check_output_dim
(labels, y)[source]
-
-
-
--
-class
pytorch_tabnet.metrics.
RMSE
[source]
-Bases: pytorch_tabnet.metrics.Metric
-Root Mean Squared Error.
-
+
+-
+
pytorch_tabnet.multiclass_utils.
check_unique_type
(y)[source]
+
-
--
-class
pytorch_tabnet.metrics.
RMSLE
[source]
-Bases: pytorch_tabnet.metrics.Metric
-Mean squared logarithmic error regression loss.
-Scikit-implementation:
-https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_squared_log_error.html
-Note: In order to avoid error, negative predictions are clipped to 0.
-This means that you should clip negative predictions manually after calling predict.
+
+-
+
pytorch_tabnet.multiclass_utils.
infer_multitask_output
(y_train)[source]
+Infer output_dim from targets
+This is for multiple tasks.
+
+- Parameters
+y_train (np.ndarray) – Training targets
+
+- Returns
+-
+
+
+
-
--
-class
pytorch_tabnet.metrics.
UnsupMetricContainer
(metric_names: List[str], prefix: str = '')[source]
-Bases: object
-Container holding a list of metrics.
+
+-
+
pytorch_tabnet.multiclass_utils.
infer_output_dim
(y_train)[source]
+Infer output_dim from targets
- Parameters
-
-y_pred (torch.Tensor or np.array) – Reconstructed prediction (with embeddings)
-embedded_x (torch.Tensor) – Original input embedded by network
-obf_vars (torch.Tensor) – Binary mask for obfuscated variables.
-1 means the variables was obfuscated so reconstruction is based on this.
+y_train (np.array) – Training targets
+
+- Returns
+-
+
-
--
-
metric_names
: List[str] = None
-
-
-
--
-
prefix
: str = ''
-
-
--
-
pytorch_tabnet.metrics.
UnsupervisedLoss
(y_pred, embedded_x, obf_vars, eps=1e-09)[source]
-Implements unsupervised loss function.
-This differs from orginal paper as it’s scaled to be batch size independent
-and number of features reconstructed independent (by taking the mean)
+-
+
pytorch_tabnet.multiclass_utils.
is_multilabel
(y)[source]
+Check if y
is in a multilabel format.
- Parameters
-
-y_pred (torch.Tensor or np.array) – Reconstructed prediction (with embeddings)
-embedded_x (torch.Tensor) – Original input embedded by network
-obf_vars (torch.Tensor) – Binary mask for obfuscated variables.
-1 means the variable was obfuscated so reconstruction is based on this.
-eps (float) – A small floating point to avoid ZeroDivisionError
-This can happen in degenerated case when a feature has only one value
-
+y (numpy array of shape [n_samples]) – Target values.
- Returns
-loss – Unsupervised loss, average value over batch samples.
+out – Return True
, if y
is in a multilabel format, else `False
.
- Return type
-torch float
+bool
+Examples
+>>> import numpy as np
+>>> from sklearn.utils.multiclass import is_multilabel
+>>> is_multilabel([0, 1, 0, 1])
+False
+>>> is_multilabel([[1], [0, 2], []])
+False
+>>> is_multilabel(np.array([[1, 0], [0, 0]]))
+True
+>>> is_multilabel(np.array([[1], [0], [0]]))
+False
+>>> is_multilabel(np.array([[1, 0, 0]]))
+True
+
+
-
--
-class
pytorch_tabnet.metrics.
UnsupervisedMetric
[source]
-Bases: pytorch_tabnet.metrics.Metric
-Unsupervised metric
+
+-
+
pytorch_tabnet.multiclass_utils.
type_of_target
(y)[source]
+Determine the type of data indicated by the target.
+Note that this type is the most specific type that can be inferred.
+For example:
+
+
+binary
is more specific but compatible with multiclass
.
+multiclass
of integers is more specific but compatible with
+continuous
.
+multilabel-indicator
is more specific but compatible with
+multiclass-multioutput
.
+
+
+
+- Parameters
+y (array-like) –
+
+- Returns
+target_type – One of:
+
+’continuous’: y is an array-like of floats that are not all
+integers, and is 1d or a column vector.
+’continuous-multioutput’: y is a 2d array of floats that are
+not all integers, and both dimensions are of size > 1.
+’binary’: y contains <= 2 discrete values and is 1d or a column
+vector.
+’multiclass’: y contains more than two discrete values, is not a
+sequence of sequences, and is 1d or a column vector.
+’multiclass-multioutput’: y is a 2d array that contains more
+than two discrete values, is not a sequence of sequences, and both
+dimensions are of size > 1.
+’multilabel-indicator’: y is a label indicator matrix, an array
+of two dimensions with at least two columns, and at most 2 unique
+values.
+’unknown’: y is array-like but none of the above, such as a 3d
+array, sequence of sequences, or an array of non-sequence objects.
+
+
+
+- Return type
+string
+
+
+Examples
+>>> import numpy as np
+>>> type_of_target([0.1, 0.6])
+'continuous'
+>>> type_of_target([1, -1, -1, 1])
+'binary'
+>>> type_of_target(['a', 'b', 'a'])
+'binary'
+>>> type_of_target([1.0, 2.0])
+'binary'
+>>> type_of_target([1, 0, 2])
+'multiclass'
+>>> type_of_target([1.0, 0.0, 3.0])
+'multiclass'
+>>> type_of_target(['a', 'b', 'c'])
+'multiclass'
+>>> type_of_target(np.array([[1, 2], [3, 1]]))
+'multiclass-multioutput'
+>>> type_of_target([[1, 2]])
+'multiclass-multioutput'
+>>> type_of_target(np.array([[1.5, 2.0], [3.0, 1.6]]))
+'continuous-multioutput'
+>>> type_of_target(np.array([[0, 1], [1, 1]]))
+'multilabel-indicator'
+
+
--
-
pytorch_tabnet.metrics.
check_metrics
(metrics)[source]
-Check if custom metrics are provided.
+-
+
pytorch_tabnet.multiclass_utils.
unique_labels
(*ys)[source]
+Extract an ordered array of unique labels
+
+- We don’t allow:
+mix of multilabel and multiclass (single label) targets
+mix of label indicator matrix and anything else,
+because there are no explicit labels)
+mix of label indicator matrices of different sizes
+mix of string and integer labels
+
+
+
+At the moment, we also don’t allow “multiclass-multioutput” input type.
- Parameters
-metrics (list of str or classes) – List with built-in metrics (str) or custom metrics (classes).
+*ys (array-likes) –
- Returns
-val_metrics – List of metric names.
+out – An ordered array of unique labels.
- Return type
-list of str
+numpy array of shape [n_unique_labels]
+Examples
+>>> from sklearn.utils.multiclass import unique_labels
+>>> unique_labels([3, 5, 5, 5, 7, 7])
+array([3, 5, 7])
+>>> unique_labels([1, 2, 3, 4], [2, 2, 3, 4])
+array([1, 2, 3, 4])
+>>> unique_labels([1, 2, 10], [5, 11])
+array([ 1, 2, 5, 10, 11])
+
+
-
-
+
+
+
diff --git a/docs/genindex.html b/docs/genindex.html
index c8dd5366..3c9e444d 100644
--- a/docs/genindex.html
+++ b/docs/genindex.html
@@ -83,14 +83,17 @@
-
Contents:
+
Contents:
@@ -253,15 +256,21 @@
C
- (pytorch_tabnet.tab_model.TabNetRegressor attribute)
-
-
|
+
|
|
- pytorch_tabnet.abstract_model (module)
+
+ - pytorch_tabnet.augmentations (module)
- pytorch_tabnet.callbacks (module)
@@ -670,6 +685,8 @@ R
|
|
+ - UnsupMetricContainer (class in pytorch_tabnet.metrics)
+
- update_fit_params() (pytorch_tabnet.abstract_model.TabModel method)
diff --git a/docs/index.html b/docs/index.html
index 454f6f35..27c3e93a 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -4,7 +4,8 @@
-
+
+
Welcome to pytorch_tabnet’s documentation! — pytorch_tabnet documentation
@@ -83,14 +84,17 @@
- Contents:
+ Contents:
@@ -158,10 +162,10 @@
-
+
Welcome to pytorch_tabnet’s documentation!
-
-
+
diff --git a/docs/py-modindex.html b/docs/py-modindex.html
index 33811ddb..6dee3c89 100644
--- a/docs/py-modindex.html
+++ b/docs/py-modindex.html
@@ -85,14 +85,17 @@
- Contents:
+ Contents:
@@ -178,6 +181,11 @@ Python Module Index
pytorch_tabnet.abstract_model |
| |
+
+ |
+
+ pytorch_tabnet.augmentations |
+ |
|
diff --git a/docs/search.html b/docs/search.html
index ab0e1e5f..54ba30a5 100644
--- a/docs/search.html
+++ b/docs/search.html
@@ -84,14 +84,17 @@
- Contents:
+ Contents:
diff --git a/docs/searchindex.js b/docs/searchindex.js
index 4d732e3f..b069376c 100644
--- a/docs/searchindex.js
+++ b/docs/searchindex.js
@@ -1 +1 @@
-Search.setIndex({docnames:["generated_docs/README","generated_docs/pytorch_tabnet","index"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":1,"sphinx.domains.index":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["generated_docs/README.md","generated_docs/pytorch_tabnet.rst","index.rst"],objects:{"pytorch_tabnet.abstract_model":{TabModel:[1,1,1,""]},"pytorch_tabnet.abstract_model.TabModel":{cat_dims:[1,2,1,""],cat_emb_dim:[1,2,1,""],cat_idxs:[1,2,1,""],clip_value:[1,2,1,""],compute_loss:[1,3,1,""],device_name:[1,2,1,""],epsilon:[1,2,1,""],explain:[1,3,1,""],fit:[1,3,1,""],gamma:[1,2,1,""],input_dim:[1,2,1,""],lambda_sparse:[1,2,1,""],load_class_attrs:[1,3,1,""],load_model:[1,3,1,""],load_weights_from_unsupervised:[1,3,1,""],mask_type:[1,2,1,""],momentum:[1,2,1,""],n_a:[1,2,1,""],n_d:[1,2,1,""],n_independent:[1,2,1,""],n_shared:[1,2,1,""],n_steps:[1,2,1,""],optimizer_fn:[1,2,1,""],optimizer_params:[1,2,1,""],output_dim:[1,2,1,""],predict:[1,3,1,""],prepare_target:[1,3,1,""],save_model:[1,3,1,""],scheduler_fn:[1,2,1,""],scheduler_params:[1,2,1,""],seed:[1,2,1,""],update_fit_params:[1,3,1,""],verbose:[1,2,1,""]},"pytorch_tabnet.callbacks":{Callback:[1,1,1,""],CallbackContainer:[1,1,1,""],EarlyStopping:[1,1,1,""],History:[1,1,1,""],LRSchedulerCallback:[1,1,1,""]},"pytorch_tabnet.callbacks.Callback":{on_batch_begin:[1,3,1,""],on_batch_end:[1,3,1,""],on_epoch_begin:[1,3,1,""],on_epoch_end:[1,3,1,""],on_train_begin:[1,3,1,""],on_train_end:[1,3,1,""],set_params:[1,3,1,""],set_trainer:[1,3,1,""]},"pytorch_tabnet.callbacks.CallbackContainer":{append:[1,3,1,""],callbacks:[1,2,1,""],on_batch_begin:[1,3,1,""],on_batch_end:[1,3,1,""],on_epoch_begin:[1,3,1,""],on_epoch_end:[1,3,1,""],on_train_begin:[1,3,1,""],on_train_end:[1,3,1,""],set_params:[1,3,1,""],set_trainer:[1,3,1,""]},"pytorch_tabnet.callbacks.EarlyStopping":{early_stopping_metric:[1,2,1,""],is_maximize:[1,2,1,""],on_epoch_end:[1,3,1,""],on_train_end:[1,3,1,""],patience:[1,2,1,""],tol:[1,2,1,""]},"pytorch_tabnet.callbacks.History":{on_batch_end:[1,3,1,""],on_epoch_begin:[1,3,1,""],on_epoch_end:[1,3,1,""],on_train_begin:[1,3,1,""],trainer:[1,2,1,""],verbose:[1,2,1,""]},"pytorch_tabnet.callbacks.LRSchedulerCallback":{early_stopping_metric:[1,2,1,""],is_batch_level:[1,2,1,""],on_batch_end:[1,3,1,""],on_epoch_end:[1,3,1,""],optimizer:[1,2,1,""],scheduler_fn:[1,2,1,""],scheduler_params:[1,2,1,""]},"pytorch_tabnet.metrics":{AUC:[1,1,1,""],Accuracy:[1,1,1,""],BalancedAccuracy:[1,1,1,""],LogLoss:[1,1,1,""],MAE:[1,1,1,""],MSE:[1,1,1,""],Metric:[1,1,1,""],MetricContainer:[1,1,1,""],RMSE:[1,1,1,""],RMSLE:[1,1,1,""],UnsupMetricContainer:[1,1,1,""],UnsupervisedLoss:[1,4,1,""],UnsupervisedMetric:[1,1,1,""],check_metrics:[1,4,1,""]},"pytorch_tabnet.metrics.Metric":{get_metrics_by_names:[1,3,1,""]},"pytorch_tabnet.metrics.MetricContainer":{metric_names:[1,2,1,""],prefix:[1,2,1,""]},"pytorch_tabnet.metrics.UnsupMetricContainer":{metric_names:[1,2,1,""],prefix:[1,2,1,""]},"pytorch_tabnet.multiclass_utils":{assert_all_finite:[1,4,1,""],check_classification_targets:[1,4,1,""],check_output_dim:[1,4,1,""],check_unique_type:[1,4,1,""],infer_multitask_output:[1,4,1,""],infer_output_dim:[1,4,1,""],is_multilabel:[1,4,1,""],type_of_target:[1,4,1,""],unique_labels:[1,4,1,""]},"pytorch_tabnet.multitask":{TabNetMultiTaskClassifier:[1,1,1,""]},"pytorch_tabnet.multitask.TabNetMultiTaskClassifier":{cat_dims:[1,2,1,""],cat_idxs:[1,2,1,""],compute_loss:[1,3,1,""],optimizer_params:[1,2,1,""],predict:[1,3,1,""],predict_proba:[1,3,1,""],prepare_target:[1,3,1,""],scheduler_params:[1,2,1,""],stack_batches:[1,3,1,""],update_fit_params:[1,3,1,""]},"pytorch_tabnet.pretraining":{TabNetPretrainer:[1,1,1,""]},"pytorch_tabnet.pretraining.TabNetPretrainer":{cat_dims:[1,2,1,""],cat_idxs:[1,2,1,""],compute_loss:[1,3,1,""],fit:[1,3,1,""],optimizer_params:[1,2,1,""],predict:[1,3,1,""],prepare_target:[1,3,1,""],scheduler_params:[1,2,1,""],stack_batches:[1,3,1,""],update_fit_params:[1,3,1,""]},"pytorch_tabnet.pretraining_utils":{create_dataloaders:[1,4,1,""],validate_eval_set:[1,4,1,""]},"pytorch_tabnet.sparsemax":{Entmax15:[1,1,1,""],Entmax15Function:[1,1,1,""],Entmoid15:[1,1,1,""],Sparsemax:[1,1,1,""],SparsemaxFunction:[1,1,1,""],entmax15:[1,4,1,""],entmoid15:[1,4,1,""],sparsemax:[1,4,1,""]},"pytorch_tabnet.sparsemax.Entmax15":{forward:[1,3,1,""]},"pytorch_tabnet.sparsemax.Entmax15Function":{backward:[1,3,1,""],forward:[1,3,1,""]},"pytorch_tabnet.sparsemax.Entmoid15":{backward:[1,3,1,""],forward:[1,3,1,""]},"pytorch_tabnet.sparsemax.Sparsemax":{forward:[1,3,1,""]},"pytorch_tabnet.sparsemax.SparsemaxFunction":{backward:[1,3,1,""],forward:[1,3,1,""]},"pytorch_tabnet.tab_model":{TabNetClassifier:[1,1,1,""],TabNetRegressor:[1,1,1,""]},"pytorch_tabnet.tab_model.TabNetClassifier":{cat_dims:[1,2,1,""],cat_idxs:[1,2,1,""],compute_loss:[1,3,1,""],optimizer_params:[1,2,1,""],predict_func:[1,3,1,""],predict_proba:[1,3,1,""],prepare_target:[1,3,1,""],scheduler_params:[1,2,1,""],stack_batches:[1,3,1,""],update_fit_params:[1,3,1,""],weight_updater:[1,3,1,""]},"pytorch_tabnet.tab_model.TabNetRegressor":{cat_dims:[1,2,1,""],cat_idxs:[1,2,1,""],compute_loss:[1,3,1,""],optimizer_params:[1,2,1,""],predict_func:[1,3,1,""],prepare_target:[1,3,1,""],scheduler_params:[1,2,1,""],stack_batches:[1,3,1,""],update_fit_params:[1,3,1,""]},"pytorch_tabnet.tab_network":{AttentiveTransformer:[1,1,1,""],EmbeddingGenerator:[1,1,1,""],FeatTransformer:[1,1,1,""],GBN:[1,1,1,""],GLU_Block:[1,1,1,""],GLU_Layer:[1,1,1,""],RandomObfuscator:[1,1,1,""],TabNet:[1,1,1,""],TabNetDecoder:[1,1,1,""],TabNetEncoder:[1,1,1,""],TabNetNoEmbeddings:[1,1,1,""],TabNetPretraining:[1,1,1,""],initialize_glu:[1,4,1,""],initialize_non_glu:[1,4,1,""]},"pytorch_tabnet.tab_network.AttentiveTransformer":{forward:[1,3,1,""]},"pytorch_tabnet.tab_network.EmbeddingGenerator":{forward:[1,3,1,""]},"pytorch_tabnet.tab_network.FeatTransformer":{forward:[1,3,1,""]},"pytorch_tabnet.tab_network.GBN":{forward:[1,3,1,""]},"pytorch_tabnet.tab_network.GLU_Block":{forward:[1,3,1,""]},"pytorch_tabnet.tab_network.GLU_Layer":{forward:[1,3,1,""]},"pytorch_tabnet.tab_network.RandomObfuscator":{forward:[1,3,1,""]},"pytorch_tabnet.tab_network.TabNet":{forward:[1,3,1,""],forward_masks:[1,3,1,""]},"pytorch_tabnet.tab_network.TabNetDecoder":{forward:[1,3,1,""]},"pytorch_tabnet.tab_network.TabNetEncoder":{forward:[1,3,1,""],forward_masks:[1,3,1,""]},"pytorch_tabnet.tab_network.TabNetNoEmbeddings":{forward:[1,3,1,""],forward_masks:[1,3,1,""]},"pytorch_tabnet.tab_network.TabNetPretraining":{forward:[1,3,1,""],forward_masks:[1,3,1,""]},"pytorch_tabnet.utils":{ComplexEncoder:[1,1,1,""],PredictDataset:[1,1,1,""],TorchDataset:[1,1,1,""],create_dataloaders:[1,4,1,""],create_explain_matrix:[1,4,1,""],create_sampler:[1,4,1,""],define_device:[1,4,1,""],filter_weights:[1,4,1,""],validate_eval_set:[1,4,1,""]},"pytorch_tabnet.utils.ComplexEncoder":{"default":[1,3,1,""]},pytorch_tabnet:{abstract_model:[1,0,0,"-"],callbacks:[1,0,0,"-"],metrics:[1,0,0,"-"],multiclass_utils:[1,0,0,"-"],multitask:[1,0,0,"-"],pretraining:[1,0,0,"-"],pretraining_utils:[1,0,0,"-"],sparsemax:[1,0,0,"-"],tab_model:[1,0,0,"-"],tab_network:[1,0,0,"-"],utils:[1,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","attribute","Python attribute"],"3":["py","method","Python method"],"4":["py","function","Python function"]},objtypes:{"0":"py:module","1":"py:class","2":"py:attribute","3":"py:method","4":"py:function"},terms:{"1st":0,"abstract":1,"boolean":1,"case":1,"class":0,"default":[1,2],"float":[0,1],"function":0,"import":[0,1],"int":[0,1],"new":[0,1],"return":[0,1],"static":1,"throw":1,"true":[0,1],"try":[0,1],"while":1,Added:0,For:1,One:1,The:[0,1],Use:1,Useful:2,Using:1,__call__:0,__init__:0,_contextmethodmixin:1,_maxim:0,_name:0,a_max:0,a_min:0,abov:1,abs:1,absolut:1,abstract_model:2,accept:1,accord:[0,1],accuraci:[0,1],adam:[0,1],after:1,afterward:1,alia:1,all:[0,1],allow:1,allow_nan:1,along:1,alpha:1,also:1,although:1,amount:1,ani:[0,1],anyth:1,append:1,appli:[0,1],arbitrari:1,architectur:0,argument:1,arik:0,arrai:[0,1],arxiv:[0,1],assert_all_finit:1,assign:0,astudillo:1,attent:[1,2],attentivetransform:1,attribut:1,auc:[0,1],auto:[0,1],autograd:1,autom:[0,1],automat:[0,1],avail:0,averag:1,avoid:1,backward:1,balanc:[0,1],balancedaccuraci:1,base:1,baseestim:1,batch:[0,1],batch_out:[],batch_siz:[0,1],becaus:[0,1],been:0,befor:[0,1],bellow:0,ben:1,best:0,better:0,between:[0,1],bigger:0,binari:[0,1],blob:0,block:1,bool:[0,1],both:1,build:[0,1],built:1,call:1,callabl:1,callback:[0,2],callbackcontain:1,can:[0,1],capac:0,care:1,cat:[],cat_dim:[0,1],cat_emb_dim:[0,1],cat_idx:[0,1],categor:[0,1],censu:[],certain:1,chang:[0,1],check:1,check_circular:1,check_classification_target:1,check_metr:1,check_nan:[],check_output_dim:1,check_unique_typ:1,choic:0,cite:1,class_attr:1,classic:[0,1],classif:[0,1],classmethod:1,clf:0,clip:[0,1],clip_valu:[0,1],clone:0,close:0,cls:1,code:2,coeffici:0,column:1,com:[0,1],compat:[0,1],complet:0,complexencod:1,comput:1,compute_loss:1,consecut:[0,1],contain:[0,1],content:2,context:1,continu:1,contribut:0,convert:1,corr:1,correct:1,correl:0,correspond:1,could:[0,1],counter:1,cpu:1,creat:[0,1],create_dataload:1,create_explain_matrix:1,create_sampl:1,cross:0,ctx:1,cuda:1,current:0,custom:[1,2],data:[0,1],dataload:[0,1],dataset:1,dblp:1,decai:0,decis:0,deduc:0,deep:1,deeprecomodel:1,def:[0,1],defin:[0,1],define_devic:1,degener:1,depend:[0,1],descript:1,detail:1,detect:[0,1],determin:1,develop:0,devic:1,device_nam:[0,1],dict:[0,1],dictionari:1,dictionnari:[0,1],did:1,differ:1,differenti:1,difficulti:0,dim:1,dimens:1,discret:1,disk:0,distinct:1,divid:0,divis:1,docker:0,doe:[1,2],doing:0,don:1,dreamquark:0,dreamquarktabnet:0,drop:[0,1],drop_last:[0,1],dure:[0,1],each:[0,1],earli:[0,1],early_stopping_metr:1,earlystop:1,easi:2,easier:0,easili:0,either:[0,1],element:1,els:1,emb:[],embded:[],embed:[0,1],embedded_x:1,embeddinggener:1,enabl:0,encod:1,end:0,ensur:1,ensure_ascii:1,entmax15:1,entmax15funct:1,entmax:[0,1],entmoid15:1,entropi:0,epoch:[0,1],eps:1,epsilon:[0,1],equal:1,equival:1,error:1,eval:[0,1,2],eval_metr:1,eval_nam:[0,1],eval_set:[0,1],evalu:[1,2],event:1,everi:[0,1],exact:1,exampl:[0,1],except:1,exit:1,expert:1,explain:1,explan:1,explanatori:0,explicit:1,extra:0,extract:1,factori:1,fals:[0,1],feattransform:1,featu:[],featur:[0,1],few:0,file:1,filepath:1,filter_weight:1,first:1,fit:[1,2],follow:[0,1],forest:[],format:1,former:1,formula:1,forward:1,forward_mask:1,found:0,frequenc:1,from:[0,1],from_unsupervis:[0,1],gamma:[0,1],gate:0,gbn:1,gener:1,get:[0,1],get_metrics_by_nam:1,ghost:[0,1],gini:0,git:0,github:[0,1],give:0,given:[0,1],glu:1,glu_block:1,glu_lay:1,good:0,gpu:1,grad_output:1,gradient:[0,1],greater:0,handl:2,happen:1,harder:0,has:[0,1],have:[0,1],help:0,here:0,highli:1,histori:1,hold:1,hook:1,hot:1,how:[1,2],html:1,http:[0,1],idx:[],ignor:1,imeplement:[],implement:[0,1],improv:[0,1],includ:0,incomplet:1,indent:1,independ:[0,1],index:[1,2],indic:[0,1],infer:1,infer_multitask_output:1,infer_output_dim:1,infin:1,initi:[0,1],initialize_glu:1,initialize_non_glu:1,input:[0,1],input_dim:1,insid:0,instal:2,instanc:1,instead:1,integ:[0,1],interpret:2,invers:[0,1],ipynb:0,is_batch_level:1,is_maxim:1,is_multilabel:1,iter:1,its:0,join:0,journal:1,json:1,jsonencod:1,jupyt:0,kaggl:0,kei:[0,1],labda:[],lambda:1,lambda_spars:[0,1],larg:0,last:[0,1],later:0,latter:1,layer:0,learn:[1,2],least:[0,1],left:[0,1],length:[0,1],let:1,like:1,line:0,linear:0,link:2,list:[0,1],list_embedded_x:1,list_obfusc:1,list_output:1,list_y_scor:1,list_y_tru:1,load:[0,1],load_class_attr:1,load_model:1,load_weights_from_unsupervis:1,local:[0,1],log:1,logarithm:1,logloss:[0,1],longtensor:1,loop:1,loss:[0,1],loss_fn:[0,1],lower:0,lr_schedul:[0,1],lrschedulercallback:1,m_explain:1,mae:[0,1],main:1,make:[0,1],mandatori:0,mani:1,manual:1,map:1,martin:1,martinsa16:1,mask:[0,1],mask_typ:[0,1],match:0,matric:1,matrix:1,max:0,max_epoch:[0,1],maxim:[0,1],maximum:[0,1],mean:[0,1],mean_squared_log_error:1,memori:1,mention:0,method:1,metric:2,metric_nam:1,metriccontain:1,might:0,mini:0,minimum:1,mix:1,moa:0,modal:0,model:[1,2],model_nam:0,modul:2,moment:1,momentum:[0,1],monitor:1,more:[0,1],most:1,mse:[0,1],multi:0,multiclass:[0,1],multiclass_util:2,multilabel:1,multioutput:1,multipl:1,multitask:[0,2],must:[0,1],n_a:[0,1],n_d:[0,1],n_glu:1,n_glu_independ:1,n_independ:[0,1],n_sampl:1,n_share:[0,1],n_step:[0,1],n_unique_label:1,name:[0,1],nan:1,ndarrai:1,need:[0,1],needs_input_grad:1,neg:[0,1],network:1,neural:1,nicula:1,non:1,none:[0,1],normal:[0,1],note:[0,1],notebook:0,now:0,num:[],num_work:[0,1],number:[0,1],numpi:1,obf_var:1,obfusc:1,obj:1,object:1,occur:[],occurr:0,on_batch_begin:1,on_batch_end:1,on_epoch_begin:1,on_epoch_end:1,on_train_begin:1,on_train_end:1,one:[0,1],onecyclelr:1,ones:0,onli:1,oper:1,optim:[0,1],optimizer_fn:[0,1],optimizer_param:[0,1],optimo:[],option:0,order:[0,1],org:[0,1],orgin:1,origin:[0,1],other:1,otherwis:1,our:0,out:1,output:1,output_dim:1,over:1,overfit:0,overridden:1,overwritten:0,own:[0,1],packag:2,page:2,paper:[0,1],param:1,paramet:[1,2],pass:1,path:[0,1],patienc:[0,1],pdf:0,per:[0,1],percentag:[0,1],perform:[0,1],peter:1,pfister:0,pin:1,pin_memori:1,pip:0,place:0,plot:0,poetri:0,point:1,posit:1,post:1,post_embed_dim:1,pre:2,pred:0,predict:[0,1],predict_func:1,predict_proba:1,predictdataset:1,prefix:1,prepar:1,prepare_target:1,preprint:0,pretrain:[0,2],pretraining_exampl:0,pretraining_ratio:[0,1],pretraining_util:2,previous:1,print:1,prior:1,probabl:1,problem:[1,2],process:1,processed_feat:1,product:1,propos:0,provid:1,pytorch:[1,2],pytorch_tabnet:0,qualifi:1,question:0,rais:1,random:[0,1],randomobfusc:1,rang:0,rapidli:1,rate:0,readm:2,realli:0,recip:1,recommend:0,reconstruct:[0,1],record:1,reduc:[0,1],reducing_matrix:1,regist:1,regress:[0,1],rel:1,repositori:0,repres:1,reproduc:0,res:1,reset:1,result:1,retriev:[0,1],reus:0,reusag:0,risk:0,rmse:[0,1],rmsle:[0,1],roc_auc_scor:0,root:1,run:[0,1],same:[0,1],sampl:[0,1],sampler:1,save:[0,1],save_model:1,saving_path:0,scale:1,schedul:[0,1],scheduler_fn:[0,1],scheduler_param:[0,1],scikit:[0,1],score:[0,1],search:2,section:0,see:[0,1],seed:[0,1],select:0,self:[0,1],semi:2,separ:1,sequenc:1,serializ:1,set:[0,1],set_param:1,set_train:1,shape:1,share:0,shared_lay:1,should:[0,1],show:1,silent:1,simpl:0,sinc:[0,1],singl:[0,1],size:[0,1],skipkei:1,sklearn:[0,1],slack:0,small:1,smaller:1,softmax:1,solut:0,sort:1,sort_kei:1,sourc:[1,2],spars:1,sparsemax:[0,2],sparsemaxfunct:1,sparser:0,sparsiti:0,specif:[0,1],specifii:0,spin:1,squar:1,stabl:1,stack_batch:1,start:[0,1],step:[0,1],step_siz:0,steplr:0,steps_output:1,stop:[0,1],store:1,str:[0,1],string:[0,1],subclass:1,subprocess:1,subsampl:1,sum:1,supermodul:1,supervis:[1,2],support:1,sure:1,tab_model:[0,2],tab_network:2,tabmodel:1,tabnet:[1,2],tabnetclassifi:[0,1],tabnetdecod:1,tabnetencod:1,tabnetmultitaskclassifi:[0,1],tabnetnoembed:1,tabnetpretrain:[0,1],tabnetregressor:[0,1],tabular:2,take:1,talk:0,target:[0,1],target_mapp:1,target_typ:1,task:[0,1],tasks_dim:1,tasks_label:1,tensor:1,term:0,termin:[0,1],than:[0,1],thei:0,them:1,thi:[0,1],tol:1,torch:[0,1],torchdataset:1,train:[1,2],train_dataload:1,train_label:1,trainer:1,trainng:0,transform:[0,1],trick:1,tupl:[0,1],two:1,type:[0,1],type_of_target:1,typeerror:1,typic:0,uniqu:[0,1],unique_label:1,unit:0,unknown:1,unsupervis:1,unsupervised_model:[0,1],unsupervisedloss:1,unsupervisedmetr:1,unsupmetriccontain:1,untouch:0,updat:1,update_fit_param:1,use:[1,2],used:[0,1],user:1,using:0,usual:0,util:[0,2],val_metr:1,valid:[0,1],valid_dataload:1,validate_eval_set:1,valu:[0,1],valueerror:1,variabl:1,vector:1,verbos:[0,1],via:0,video:0,virtual:[],virtual_batch_s:[0,1],vlad:1,wait:1,wan:0,want:0,weight:[0,1],weight_updat:1,were:1,what:2,when:[0,1],where:[0,1],whether:[0,1],which:1,width:0,wihtout:[],within:[0,1],without:[0,1],worker:[0,1],wors:0,wrapper:1,wrong:1,www:[],x_predict:0,x_test:0,x_train:[0,1],x_valid:0,y_pred:1,y_score:[0,1],y_train:[0,1],y_true:[0,1],y_valid:0,you:[0,1],your:0,youtu:[],ysbazo8ymx8:[],zerodivisionerror:1,zip:1},titles:["README","pytorch_tabnet package","Welcome to pytorch_tabnet\u2019s documentation!"],titleterms:{"class":1,"default":0,"function":1,Useful:0,abstract_model:1,attent:0,callback:1,code:0,cpu:0,custom:0,doc:[],document:2,doe:0,early_stopping_metr:[],easi:0,eval_metr:0,evalu:0,fit:0,gpu:0,handl:0,how:0,indic:2,instal:0,interpret:0,label:1,learn:0,link:0,metric:[0,1],model:0,modul:1,multi:1,multiclass_util:1,multitask:1,onli:0,packag:1,paramet:0,pre:0,pretrain:1,pretraining_util:1,problem:0,pytorch:0,pytorch_tabnet:[1,2],readm:0,script:[],semi:0,sourc:0,sparsemax:1,supervis:0,tab_model:1,tab_network:1,tabl:2,tabnet:0,tabular:0,train:0,use:0,util:1,welcom:2,what:0}})
\ No newline at end of file
+Search.setIndex({docnames:["generated_docs/README","generated_docs/pytorch_tabnet","index"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":1,"sphinx.domains.index":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["generated_docs/README.md","generated_docs/pytorch_tabnet.rst","index.rst"],objects:{"pytorch_tabnet.abstract_model":{TabModel:[1,1,1,""]},"pytorch_tabnet.abstract_model.TabModel":{cat_dims:[1,2,1,""],cat_emb_dim:[1,2,1,""],cat_idxs:[1,2,1,""],clip_value:[1,2,1,""],compute_loss:[1,3,1,""],device_name:[1,2,1,""],epsilon:[1,2,1,""],explain:[1,3,1,""],fit:[1,3,1,""],gamma:[1,2,1,""],input_dim:[1,2,1,""],lambda_sparse:[1,2,1,""],load_class_attrs:[1,3,1,""],load_model:[1,3,1,""],load_weights_from_unsupervised:[1,3,1,""],mask_type:[1,2,1,""],momentum:[1,2,1,""],n_a:[1,2,1,""],n_d:[1,2,1,""],n_indep_decoder:[1,2,1,""],n_independent:[1,2,1,""],n_shared:[1,2,1,""],n_shared_decoder:[1,2,1,""],n_steps:[1,2,1,""],optimizer_fn:[1,2,1,""],optimizer_params:[1,2,1,""],output_dim:[1,2,1,""],predict:[1,3,1,""],prepare_target:[1,3,1,""],save_model:[1,3,1,""],scheduler_fn:[1,2,1,""],scheduler_params:[1,2,1,""],seed:[1,2,1,""],update_fit_params:[1,3,1,""],verbose:[1,2,1,""]},"pytorch_tabnet.augmentations":{ClassificationSMOTE:[1,1,1,""],RegressionSMOTE:[1,1,1,""]},"pytorch_tabnet.callbacks":{Callback:[1,1,1,""],CallbackContainer:[1,1,1,""],EarlyStopping:[1,1,1,""],History:[1,1,1,""],LRSchedulerCallback:[1,1,1,""]},"pytorch_tabnet.callbacks.Callback":{on_batch_begin:[1,3,1,""],on_batch_end:[1,3,1,""],on_epoch_begin:[1,3,1,""],on_epoch_end:[1,3,1,""],on_train_begin:[1,3,1,""],on_train_end:[1,3,1,""],set_params:[1,3,1,""],set_trainer:[1,3,1,""]},"pytorch_tabnet.callbacks.CallbackContainer":{append:[1,3,1,""],callbacks:[1,2,1,""],on_batch_begin:[1,3,1,""],on_batch_end:[1,3,1,""],on_epoch_begin:[1,3,1,""],on_epoch_end:[1,3,1,""],on_train_begin:[1,3,1,""],on_train_end:[1,3,1,""],set_params:[1,3,1,""],set_trainer:[1,3,1,""]},"pytorch_tabnet.callbacks.EarlyStopping":{early_stopping_metric:[1,2,1,""],is_maximize:[1,2,1,""],on_epoch_end:[1,3,1,""],on_train_end:[1,3,1,""],patience:[1,2,1,""],tol:[1,2,1,""]},"pytorch_tabnet.callbacks.History":{on_batch_end:[1,3,1,""],on_epoch_begin:[1,3,1,""],on_epoch_end:[1,3,1,""],on_train_begin:[1,3,1,""],trainer:[1,2,1,""],verbose:[1,2,1,""]},"pytorch_tabnet.callbacks.LRSchedulerCallback":{early_stopping_metric:[1,2,1,""],is_batch_level:[1,2,1,""],on_batch_end:[1,3,1,""],on_epoch_end:[1,3,1,""],optimizer:[1,2,1,""],scheduler_fn:[1,2,1,""],scheduler_params:[1,2,1,""]},"pytorch_tabnet.metrics":{AUC:[1,1,1,""],Accuracy:[1,1,1,""],BalancedAccuracy:[1,1,1,""],LogLoss:[1,1,1,""],MAE:[1,1,1,""],MSE:[1,1,1,""],Metric:[1,1,1,""],MetricContainer:[1,1,1,""],RMSE:[1,1,1,""],RMSLE:[1,1,1,""],UnsupMetricContainer:[1,1,1,""],UnsupervisedLoss:[1,4,1,""],UnsupervisedLossNumpy:[1,4,1,""],UnsupervisedMetric:[1,1,1,""],UnsupervisedNumpyMetric:[1,1,1,""],check_metrics:[1,4,1,""]},"pytorch_tabnet.metrics.Metric":{get_metrics_by_names:[1,3,1,""]},"pytorch_tabnet.metrics.MetricContainer":{metric_names:[1,2,1,""],prefix:[1,2,1,""]},"pytorch_tabnet.metrics.UnsupMetricContainer":{metric_names:[1,2,1,""],prefix:[1,2,1,""]},"pytorch_tabnet.multiclass_utils":{assert_all_finite:[1,4,1,""],check_classification_targets:[1,4,1,""],check_output_dim:[1,4,1,""],check_unique_type:[1,4,1,""],infer_multitask_output:[1,4,1,""],infer_output_dim:[1,4,1,""],is_multilabel:[1,4,1,""],type_of_target:[1,4,1,""],unique_labels:[1,4,1,""]},"pytorch_tabnet.multitask":{TabNetMultiTaskClassifier:[1,1,1,""]},"pytorch_tabnet.multitask.TabNetMultiTaskClassifier":{cat_dims:[1,2,1,""],cat_idxs:[1,2,1,""],compute_loss:[1,3,1,""],optimizer_params:[1,2,1,""],predict:[1,3,1,""],predict_proba:[1,3,1,""],prepare_target:[1,3,1,""],scheduler_params:[1,2,1,""],stack_batches:[1,3,1,""],update_fit_params:[1,3,1,""]},"pytorch_tabnet.pretraining":{TabNetPretrainer:[1,1,1,""]},"pytorch_tabnet.pretraining.TabNetPretrainer":{cat_dims:[1,2,1,""],cat_idxs:[1,2,1,""],compute_loss:[1,3,1,""],fit:[1,3,1,""],optimizer_params:[1,2,1,""],predict:[1,3,1,""],prepare_target:[1,3,1,""],scheduler_params:[1,2,1,""],stack_batches:[1,3,1,""],update_fit_params:[1,3,1,""]},"pytorch_tabnet.pretraining_utils":{create_dataloaders:[1,4,1,""],validate_eval_set:[1,4,1,""]},"pytorch_tabnet.sparsemax":{Entmax15:[1,1,1,""],Entmax15Function:[1,1,1,""],Entmoid15:[1,1,1,""],Sparsemax:[1,1,1,""],SparsemaxFunction:[1,1,1,""],entmax15:[1,4,1,""],entmoid15:[1,4,1,""],sparsemax:[1,4,1,""]},"pytorch_tabnet.sparsemax.Entmax15":{forward:[1,3,1,""]},"pytorch_tabnet.sparsemax.Entmax15Function":{backward:[1,3,1,""],forward:[1,3,1,""]},"pytorch_tabnet.sparsemax.Entmoid15":{backward:[1,3,1,""],forward:[1,3,1,""]},"pytorch_tabnet.sparsemax.Sparsemax":{forward:[1,3,1,""]},"pytorch_tabnet.sparsemax.SparsemaxFunction":{backward:[1,3,1,""],forward:[1,3,1,""]},"pytorch_tabnet.tab_model":{TabNetClassifier:[1,1,1,""],TabNetRegressor:[1,1,1,""]},"pytorch_tabnet.tab_model.TabNetClassifier":{cat_dims:[1,2,1,""],cat_idxs:[1,2,1,""],compute_loss:[1,3,1,""],optimizer_params:[1,2,1,""],predict_func:[1,3,1,""],predict_proba:[1,3,1,""],prepare_target:[1,3,1,""],scheduler_params:[1,2,1,""],stack_batches:[1,3,1,""],update_fit_params:[1,3,1,""],weight_updater:[1,3,1,""]},"pytorch_tabnet.tab_model.TabNetRegressor":{cat_dims:[1,2,1,""],cat_idxs:[1,2,1,""],compute_loss:[1,3,1,""],optimizer_params:[1,2,1,""],predict_func:[1,3,1,""],prepare_target:[1,3,1,""],scheduler_params:[1,2,1,""],stack_batches:[1,3,1,""],update_fit_params:[1,3,1,""]},"pytorch_tabnet.tab_network":{AttentiveTransformer:[1,1,1,""],EmbeddingGenerator:[1,1,1,""],FeatTransformer:[1,1,1,""],GBN:[1,1,1,""],GLU_Block:[1,1,1,""],GLU_Layer:[1,1,1,""],RandomObfuscator:[1,1,1,""],TabNet:[1,1,1,""],TabNetDecoder:[1,1,1,""],TabNetEncoder:[1,1,1,""],TabNetNoEmbeddings:[1,1,1,""],TabNetPretraining:[1,1,1,""],initialize_glu:[1,4,1,""],initialize_non_glu:[1,4,1,""]},"pytorch_tabnet.tab_network.AttentiveTransformer":{forward:[1,3,1,""]},"pytorch_tabnet.tab_network.EmbeddingGenerator":{forward:[1,3,1,""]},"pytorch_tabnet.tab_network.FeatTransformer":{forward:[1,3,1,""]},"pytorch_tabnet.tab_network.GBN":{forward:[1,3,1,""]},"pytorch_tabnet.tab_network.GLU_Block":{forward:[1,3,1,""]},"pytorch_tabnet.tab_network.GLU_Layer":{forward:[1,3,1,""]},"pytorch_tabnet.tab_network.RandomObfuscator":{forward:[1,3,1,""]},"pytorch_tabnet.tab_network.TabNet":{forward:[1,3,1,""],forward_masks:[1,3,1,""]},"pytorch_tabnet.tab_network.TabNetDecoder":{forward:[1,3,1,""]},"pytorch_tabnet.tab_network.TabNetEncoder":{forward:[1,3,1,""],forward_masks:[1,3,1,""]},"pytorch_tabnet.tab_network.TabNetNoEmbeddings":{forward:[1,3,1,""],forward_masks:[1,3,1,""]},"pytorch_tabnet.tab_network.TabNetPretraining":{forward:[1,3,1,""],forward_masks:[1,3,1,""]},"pytorch_tabnet.utils":{ComplexEncoder:[1,1,1,""],PredictDataset:[1,1,1,""],TorchDataset:[1,1,1,""],check_input:[1,4,1,""],check_warm_start:[1,4,1,""],create_dataloaders:[1,4,1,""],create_explain_matrix:[1,4,1,""],create_sampler:[1,4,1,""],define_device:[1,4,1,""],filter_weights:[1,4,1,""],validate_eval_set:[1,4,1,""]},"pytorch_tabnet.utils.ComplexEncoder":{"default":[1,3,1,""]},pytorch_tabnet:{abstract_model:[1,0,0,"-"],augmentations:[1,0,0,"-"],callbacks:[1,0,0,"-"],metrics:[1,0,0,"-"],multiclass_utils:[1,0,0,"-"],multitask:[1,0,0,"-"],pretraining:[1,0,0,"-"],pretraining_utils:[1,0,0,"-"],sparsemax:[1,0,0,"-"],tab_model:[1,0,0,"-"],tab_network:[1,0,0,"-"],utils:[1,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","attribute","Python attribute"],"3":["py","method","Python method"],"4":["py","function","Python function"]},objtypes:{"0":"py:module","1":"py:class","2":"py:attribute","3":"py:method","4":"py:function"},terms:{"1st":0,"abstract":1,"boolean":1,"case":1,"class":0,"default":[1,2],"float":[0,1],"function":0,"import":[0,1],"int":[0,1],"new":[0,1],"return":[0,1],"static":1,"throw":1,"true":[0,1],"try":[0,1],"while":1,Added:0,For:1,One:1,The:[0,1],Use:1,Useful:2,Using:1,__call__:0,__init__:0,_contextmethodmixin:1,_maxim:0,_name:0,a_max:0,a_min:0,about:1,abov:1,abs:1,absolut:1,abstract_model:2,accept:1,accord:[0,1],accuraci:[0,1],adam:[0,1],added:0,after:1,afterward:1,alia:1,all:[0,1],allow:[0,1],allow_nan:1,along:1,alpha:1,alreadi:0,also:1,although:1,ambigu:1,amount:1,ani:[0,1],anyth:1,api:0,append:1,appli:[0,1],arbitrari:1,architectur:0,argument:1,arik:0,arrai:[0,1],arxiv:[0,1],assert_all_finit:1,assign:0,astudillo:1,attent:[1,2],attentivetransform:1,attribut:1,auc:[0,1],augment:2,auto:[0,1],autograd:1,autom:[0,1],automat:[0,1],avail:0,averag:1,avoid:1,backward:1,balanc:[0,1],balancedaccuraci:1,base:1,baseestim:1,basic:0,batch:[0,1],batch_out:[],batch_siz:[0,1],becaus:[0,1],been:0,befor:[0,1],bellow:0,below:0,ben:1,best:0,beta:1,better:0,between:[0,1],bigger:0,binari:[0,1],blob:0,block:[0,1],bool:[0,1],both:1,build:[0,1],built:1,call:1,callabl:1,callback:[0,2],callbackcontain:1,can:[0,1],capac:0,care:1,cat:[],cat_dim:[0,1],cat_emb_dim:[0,1],cat_idx:[0,1],categor:[0,1],censu:[],certain:1,chang:[0,1],check:1,check_circular:1,check_classification_target:1,check_input:1,check_metr:1,check_nan:[],check_output_dim:1,check_unique_typ:1,check_warm_start:1,choic:0,cite:1,class_attr:1,classic:[0,1],classif:[0,1],classificationsmot:[0,1],classmethod:1,clear:1,clf:0,clip:[0,1],clip_valu:[0,1],clone:0,close:0,cls:1,code:2,coeffici:0,column:1,com:[0,1],commit:0,compat:[0,1],complet:0,complexencod:1,comput:1,compute_loss:1,conda:0,consecut:[0,1],contain:[0,1],content:2,context:1,continu:1,contribut:2,convert:1,corr:1,correct:1,correl:0,correspond:1,could:[0,1],counter:1,cpu:1,creat:[0,1],create_dataload:1,create_explain_matrix:1,create_sampl:1,cross:0,ctx:1,cuda:1,current:[0,1],custom:[1,2],data:[1,2],datafram:1,dataload:[0,1],dataset:1,dblp:1,decai:0,decis:0,decod:0,deduc:0,deep:1,deeprecomodel:1,def:[0,1],defin:[0,1],define_devic:1,degener:1,depend:[0,1],descript:1,detail:1,detect:[0,1],determin:1,develop:0,devic:1,device_nam:[0,1],dict:[0,1],dictionari:1,dictionnari:[0,1],did:1,differ:1,differenti:1,difficulti:0,dim:1,dimens:1,discret:1,discuss:0,disk:0,distinct:1,distribut:1,divid:0,divis:1,docker:0,doe:[1,2],doing:0,don:1,dreamquark:0,dreamquarktabnet:0,drop:[0,1],drop_last:[0,1],dure:[0,1],each:[0,1],earli:[0,1],early_stopping_metr:1,earlystop:1,easi:2,easier:0,easili:0,either:[0,1],element:1,els:1,emb:[],embded:[],embed:[0,1],embedded_x:1,embeddinggener:1,enabl:0,encod:1,end:0,ensur:1,ensure_ascii:1,entmax15:1,entmax15funct:1,entmax:[0,1],entmoid15:1,entropi:0,epoch:[0,1],eps:1,epsilon:[0,1],equal:1,equival:1,error:1,eval:[0,1,2],eval_metr:1,eval_nam:[0,1],eval_set:[0,1],evalu:[1,2],event:1,everi:[0,1],exact:1,exampl:[0,1],except:1,exist:0,exit:1,expert:1,explain:1,explan:1,explanatori:0,explicit:1,extra:0,extract:1,factori:1,fals:[0,1],feattransform:1,featu:[],featur:[0,1],few:0,file:1,filepath:1,filter_weight:1,first:[0,1],fit:[1,2],fly:2,follow:[0,1],forest:[],forg:0,format:1,former:1,formula:1,forward:1,forward_mask:1,found:0,frequenc:1,from:[0,1],from_unsupervis:[0,1],further:0,gamma:[0,1],gate:0,gbn:1,gener:1,get:[0,1],get_metrics_by_nam:1,ghost:[0,1],gini:0,git:0,github:[0,1],give:[0,1],given:[0,1],glu:[0,1],glu_block:1,glu_lay:1,good:0,gpu:1,grad_output:1,gradient:[0,1],greater:0,handl:2,happen:1,harder:0,has:[0,1],have:[0,1],help:0,here:0,highli:1,histori:1,hold:1,hook:1,hot:1,how:[1,2],html:1,http:[0,1],idx:[],ignor:1,imeplement:[],implement:[0,1],improv:[0,1],includ:0,incomplet:1,indent:1,independ:[0,1],index:[1,2],indic:[0,1],infer:1,infer_multitask_output:1,infer_output_dim:1,infin:1,initi:[0,1],initialize_glu:1,initialize_non_glu:1,input:[0,1],input_dim:1,insid:0,instal:2,instanc:1,instead:1,integ:[0,1],interpret:2,invers:[0,1],ipynb:0,is_batch_level:1,is_maxim:1,is_multilabel:1,issu:0,iter:1,its:0,join:0,journal:1,json:1,jsonencod:1,jupyt:0,kaggl:0,keep:1,kei:[0,1],labda:[],lambda:1,lambda_spars:[0,1],larg:0,last:[0,1],later:0,latter:1,layer:0,learn:[1,2],least:[0,1],left:[0,1],length:[0,1],let:1,like:1,line:0,linear:0,link:2,list:[0,1],list_embedded_x:1,list_obfusc:1,list_output:1,list_y_scor:1,list_y_tru:1,load:[1,2],load_class_attr:1,load_model:[0,1],load_weights_from_unsupervis:1,loaded_clf:0,local:[0,1],log:1,logarithm:1,logloss:[0,1],longtensor:1,loop:1,loss:[0,1],loss_fn:[0,1],lower:0,lr_schedul:[0,1],lrschedulercallback:1,m_explain:1,mae:[0,1],main:1,make:[0,1],mandatori:0,mani:1,manual:1,map:1,martin:1,martinsa16:1,mask:[0,1],mask_typ:[0,1],match:0,matric:1,matrix:1,max:0,max_epoch:[0,1],maxim:[0,1],maximum:[0,1],mean:[0,1],mean_squared_log_error:1,memori:1,mention:0,method:1,metric:2,metric_nam:1,metriccontain:1,might:[0,1],mini:0,minimum:1,mix:1,moa:0,modal:0,model:[1,2],model_nam:0,modul:2,moment:1,momentum:[0,1],monitor:1,more:[0,1],most:1,mse:[0,1],multi:0,multiclass:[0,1],multiclass_util:2,multilabel:1,multioutput:1,multipl:1,multitask:[0,2],must:[0,1],n_a:[0,1],n_d:[0,1],n_glu:1,n_glu_independ:1,n_indep_decod:[0,1],n_independ:[0,1],n_sampl:1,n_share:[0,1],n_shared_decod:[0,1],n_step:[0,1],n_unique_label:1,name:[0,1],nan:1,ndarrai:1,need:[0,1],needs_input_grad:1,neg:[0,1],network:1,neural:1,nicula:1,non:1,none:[0,1],normal:[0,1],note:[0,1],notebook:0,now:0,num:[],num_work:[0,1],number:[0,1],numpi:1,obf_var:1,obfusc:1,obj:1,object:1,occur:[],occurr:0,on_batch_begin:1,on_batch_end:1,on_epoch_begin:1,on_epoch_end:1,on_train_begin:1,on_train_end:1,one:[0,1],onecyclelr:1,ones:0,onli:1,oper:1,optim:[0,1],optimizer_fn:[0,1],optimizer_param:[0,1],optimo:[],option:0,order:[0,1],org:[0,1],orgin:1,origin:[0,1],other:1,otherwis:1,our:0,out:1,output:1,output_dim:1,over:1,overfit:0,overridden:1,overwritten:0,own:[0,1],packag:2,page:2,panda:1,paper:[0,1],param:1,paramet:[1,2],pass:1,path:1,patienc:[0,1],pdf:0,per:[0,1],percentag:[0,1],perform:[0,1],peter:1,pfister:0,pin:1,pin_memori:1,pip:0,pipelin:0,place:0,pleas:0,plot:0,poetri:0,point:1,posit:1,possibl:0,post:1,post_embed_dim:1,pre:2,pred:0,predict:[0,1],predict_func:1,predict_proba:1,predictdataset:1,prefix:1,prepar:1,prepare_target:1,preprint:0,present:0,pretrain:[0,2],pretraining_exampl:0,pretraining_ratio:[0,1],pretraining_util:2,previous:1,print:1,prior:1,probabl:1,problem:[1,2],process:1,processed_feat:1,product:[0,1],propos:0,provid:1,pytorch:[1,2],pytorch_tabnet:0,qualifi:1,question:0,rais:1,random:[0,1],randomobfusc:1,rang:0,rapidli:1,rate:0,readi:0,readm:2,realli:0,recip:1,recommend:0,reconstruct:[0,1],record:1,reduc:[0,1],reducing_matrix:1,regist:1,regress:[0,1],regressionsmot:[0,1],rel:1,repositori:0,repres:1,reproduc:0,res:1,reset:1,result:1,retriev:[0,1],reus:0,reusag:0,risk:0,rmse:[0,1],rmsle:[0,1],roc_auc_scor:0,root:1,row:1,rule:[0,1],run:1,same:[0,1],sampl:[0,1],sampler:1,save:[1,2],save_model:[0,1],saved_filepath:0,saving_path:[],saving_path_nam:0,scale:1,schedul:[0,1],scheduler_fn:[0,1],scheduler_param:[0,1],scikit:[0,1],score:[0,1],search:2,section:[],see:[0,1],seed:[0,1],select:0,self:[0,1],semi:2,separ:1,sequenc:1,serializ:1,set:[0,1],set_param:1,set_train:1,shape:1,share:0,shared_lay:1,should:[0,1],show:1,silent:1,simpl:0,sinc:[0,1],singl:[0,1],size:[0,1],skipkei:1,sklearn:[0,1],slack:0,small:1,smaller:1,smote:1,softmax:1,solut:0,sort:1,sort_kei:1,sourc:[1,2],spars:1,sparsemax:[0,2],sparsemaxfunct:1,sparser:0,sparsiti:0,specif:[0,1],specifii:0,spin:1,squar:1,stabl:1,stack_batch:1,stai:1,start:[0,1],state:0,step:[0,1],step_siz:0,steplr:0,steps_output:1,stop:[0,1],store:1,str:[0,1],string:[0,1],subclass:1,subprocess:1,subsampl:1,sum:1,supermodul:1,supervis:[1,2],support:1,sure:[0,1],tab_model:[0,2],tab_network:2,tabmodel:1,tabnet:[1,2],tabnet_model_test_1:0,tabnetclassifi:[0,1],tabnetdecod:1,tabnetencod:1,tabnetmultitaskclassifi:[0,1],tabnetnoembed:1,tabnetpretrain:[0,1],tabnetregressor:[0,1],tabular:2,take:1,talk:0,target:[0,1],target_mapp:1,target_typ:1,task:[0,1],tasks_dim:1,tasks_label:1,templat:0,tensor:1,term:0,termin:[0,1],than:[0,1],thei:0,them:1,thi:[0,1],tol:1,torch:[0,1],torchdataset:1,train:[1,2],train_dataload:1,train_label:1,trainer:1,trainng:0,transform:[0,1],trick:1,tupl:[0,1],twice:0,two:1,type:[0,1],type_of_target:1,typeerror:1,typic:0,unchang:1,uniqu:[0,1],unique_label:1,unit:0,unknown:1,unsupervis:1,unsupervised_model:[0,1],unsupervisedloss:1,unsupervisedlossnumpi:1,unsupervisedmetr:1,unsupervisednumpymetr:1,unsupmetriccontain:1,untouch:0,updat:1,update_fit_param:1,usag:1,use:[1,2],used:[0,1],useful:0,user:1,using:0,usual:0,util:[0,2],val_metr:1,valid:[0,1],valid_dataload:1,validate_eval_set:1,valu:[0,1],valueerror:1,variabl:1,vector:1,verbos:[0,1],via:0,video:0,virtual:[],virtual_batch_s:[0,1],vlad:1,wait:1,wan:0,want:0,warm:0,warm_start:[0,1],warn:1,weight:[0,1],weight_updat:1,well:1,were:1,what:2,when:[0,1],where:1,wheter:1,whether:[0,1],which:1,width:0,wihtout:[],wish:0,within:[0,1],without:[0,1],work:1,worker:[0,1],wors:0,wrapper:1,wrong:1,www:[],x_predict:0,x_test:0,x_train:[0,1],x_valid:0,y_pred:1,y_score:[0,1],y_train:[0,1],y_true:[0,1],y_valid:0,you:[0,1],your:0,youtu:[],ysbazo8ymx8:[],zerodivisionerror:1,zip:1},titles:["README","pytorch_tabnet package","Welcome to pytorch_tabnet\u2019s documentation!"],titleterms:{"class":1,"default":0,"function":1,Useful:0,abstract_model:1,attent:0,augment:[0,1],callback:1,code:0,contribut:0,cpu:0,custom:0,data:0,doc:[],document:2,doe:0,early_stopping_metr:[],easi:0,eval_metr:0,evalu:0,fit:0,fly:0,gpu:0,handl:0,how:0,indic:2,instal:0,interpret:0,label:1,learn:0,link:0,load:0,metric:[0,1],model:0,modul:1,multi:1,multiclass_util:1,multitask:1,onli:0,packag:1,paramet:0,pre:0,pretrain:1,pretraining_util:1,problem:0,pytorch:0,pytorch_tabnet:[1,2],readm:0,save:0,script:[],semi:0,sourc:0,sparsemax:1,supervis:0,tab_model:1,tab_network:1,tabl:2,tabnet:0,tabular:0,train:0,use:0,util:1,welcom:2,what:0}})
\ No newline at end of file
diff --git a/pyproject.toml b/pyproject.toml
index 1f96b264..f9fa0916 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pytorch_tabnet"
-version = "3.1.1"
+version = "4.0"
description = "PyTorch implementation of TabNet"
homepage = "https://github.com/dreamquark-ai/tabnet"
repository = "https://github.com/dreamquark-ai/tabnet"
|
|