Supervised Models
Configuration Classes
pytorch_tabular.models.AutoIntConfig
dataclass
Bases: ModelConfig
AutomaticFeatureInteraction configuration
PARAMETER | DESCRIPTION |
---|---|
attn_embed_dim |
The number of hidden units in the Multi-Headed Attention layers. Defaults to 32
TYPE:
|
num_heads |
The number of heads in the Multi-Headed Attention layer. Defaults to 2
TYPE:
|
num_attn_blocks |
The number of layers of stacked Multi-Headed Attention layers. Defaults to 2
TYPE:
|
attn_dropouts |
Dropout between layers of Multi-Headed Attention Layers. Defaults to 0.0
TYPE:
|
has_residuals |
Flag to have a residual connect from enbedded output to attention layer output. Defaults to True
TYPE:
|
embedding_dim |
The dimensions of the embedding for continuous and categorical columns. Defaults to 16
TYPE:
|
embedding_initialization |
Initialization scheme for the embedding layers. Defaults
to
TYPE:
|
embedding_bias |
Flag to turn on Embedding Bias. Defaults to True
TYPE:
|
share_embedding |
The flag turns on shared embeddings in the input embedding process. The key idea here is to have an embedding for the feature as a whole along with embeddings of each unique values of that column. For more details refer to Appendix A of the TabTransformer paper. Defaults to False
TYPE:
|
share_embedding_strategy |
There are two strategies in adding shared embeddings. 1.
TYPE:
|
shared_embedding_fraction |
Fraction of the input_embed_dim to be reserved by the shared embedding. Should be less than one. Defaults to 0.25
TYPE:
|
deep_layers |
Flag to enable a deep MLP layer before the Multi-Headed Attention layer. Defaults to False
TYPE:
|
layers |
Hyphen-separated number of layers and units in the deep MLP. Defaults to 128-64-32
TYPE:
|
activation |
The activation type in the deep MLP. The default activaion in PyTorch like ReLU, TanH, LeakyReLU, etc. https://pytorch.org/docs/stable/nn.html#non-linear-activations-weighted-sum- nonlinearity. Defaults to ReLU
TYPE:
|
use_batch_norm |
Flag to include a BatchNorm layer after each Linear Layer+DropOut in the deep MLP. Defaults to False
TYPE:
|
initialization |
Initialization scheme for the linear layers in the deep MLP. Defaults to
TYPE:
|
dropout |
probability of an element to be zeroed in the deep MLP. Defaults to 0.0
TYPE:
|
attention_pooling |
If True, will combine the attention outputs of each block for final prediction. Defaults to False
TYPE:
|
task |
Specify whether the problem is regression or classification.
TYPE:
|
head |
The head to be used for the model. Should be one of the heads defined in
TYPE:
|
head_config |
The config as a dict which defines the head. If left empty, will be initialized as default linear head.
TYPE:
|
embedding_dims |
The dimensions of the embedding for each categorical column as a list of tuples (cardinality, embedding_dim). If left empty, will infer using the cardinality of the categorical column using the rule min(50, (x + 1) // 2)
TYPE:
|
embedding_dropout |
Dropout to be applied to the Categorical Embedding. Defaults to 0.1
TYPE:
|
batch_norm_continuous_input |
If True, we will normalize the continuous layer by passing it through a BatchNorm layer.
TYPE:
|
learning_rate |
The learning rate of the model. Defaults to 1e-3.
TYPE:
|
loss |
The loss function to be applied. By Default it is MSELoss for regression and CrossEntropyLoss for classification. Unless you are sure what you are doing, leave it at MSELoss or L1Loss for regression and CrossEntropyLoss for classification
TYPE:
|
metrics |
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in
TYPE:
|
metrics_params |
The parameters to be passed to the metrics function
TYPE:
|
metrics_prob_input |
Is a mandatory parameter for classification metrics defined in the config. This defines whether the input to the metric function is the probability or the class. Length should be same as the number of metrics. Defaults to None.
TYPE:
|
target_range |
The range in which we should limit the output variable. Currently ignored for multi-target regression. Typically used for Regression problems. If left empty, will not apply any restrictions
TYPE:
|
seed |
The seed for reproducibility. Defaults to 42
TYPE:
|
pytorch_tabular.models.CategoryEmbeddingModelConfig
dataclass
Bases: ModelConfig
CategoryEmbeddingModel configuration
PARAMETER | DESCRIPTION |
---|---|
layers |
Hyphen-separated number of layers and units in the classification head. eg. 32-64-32. Defaults to 128-64-32
TYPE:
|
activation |
The activation type in the classification head. The default activaion in PyTorch like ReLU, TanH, LeakyReLU, etc. https://pytorch.org/docs/stable/nn.html#non-linear-activations-weighted-sum-nonlinearity. Defaults to ReLU
TYPE:
|
use_batch_norm |
Flag to include a BatchNorm layer after each Linear Layer+DropOut. Defaults to False
TYPE:
|
initialization |
Initialization scheme for the linear layers. Defaults to
TYPE:
|
dropout |
probability of an classification element to be zeroed. This is added to each linear layer. Defaults to 0.0
TYPE:
|
task |
Specify whether the problem is regression or classification.
TYPE:
|
head |
The head to be used for the model. Should be one of the heads defined in
TYPE:
|
head_config |
The config as a dict which defines the head. If left empty, will be initialized as default linear head.
TYPE:
|
embedding_dims |
The dimensions of the embedding for each categorical column as a list of tuples (cardinality, embedding_dim). If left empty, will infer using the cardinality of the categorical column using the rule min(50, (x + 1) // 2)
TYPE:
|
embedding_dropout |
Dropout to be applied to the Categorical Embedding. Defaults to 0.1
TYPE:
|
batch_norm_continuous_input |
If True, we will normalize the continuous layer by passing it through a BatchNorm layer.
TYPE:
|
learning_rate |
The learning rate of the model. Defaults to 1e-3.
TYPE:
|
loss |
The loss function to be applied. By Default it is MSELoss for regression and CrossEntropyLoss for classification. Unless you are sure what you are doing, leave it at MSELoss or L1Loss for regression and CrossEntropyLoss for classification
TYPE:
|
metrics |
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in
TYPE:
|
metrics_params |
The parameters to be passed to the metrics function.
TYPE:
|
metrics_prob_input |
Is a mandatory parameter for classification metrics defined in the config. This defines whether the input to the metric function is the probability or the class. Length should be same as the number of metrics. Defaults to None.
TYPE:
|
target_range |
The range in which we should limit the output variable. Currently ignored for multi-target regression. Typically used for Regression problems. If left empty, will not apply any restrictions
TYPE:
|
seed |
The seed for reproducibility. Defaults to 42
TYPE:
|
pytorch_tabular.models.FTTransformerConfig
dataclass
Bases: ModelConfig
Tab Transformer configuration
PARAMETER | DESCRIPTION |
---|---|
input_embed_dim |
The embedding dimension for the input categorical features. Defaults to 32
TYPE:
|
embedding_initialization |
Initialization scheme for the embedding layers. Defaults
to
TYPE:
|
embedding_bias |
Flag to turn on Embedding Bias. Defaults to True
TYPE:
|
share_embedding |
The flag turns on shared embeddings in the input embedding process. The key idea here is to have an embedding for the feature as a whole along with embeddings of each unique values of that column. For more details refer to Appendix A of the TabTransformer paper. Defaults to False
TYPE:
|
share_embedding_strategy |
There are two strategies in adding shared embeddings. 1.
TYPE:
|
shared_embedding_fraction |
Fraction of the input_embed_dim to be reserved by the shared embedding. Should be less than one. Defaults to 0.25
TYPE:
|
attn_feature_importance |
If you are facing memory issues, you can turn off feature importance which will not save the attention weights. Defaults to True
TYPE:
|
num_heads |
The number of heads in the Multi-Headed Attention layer. Defaults to 8
TYPE:
|
num_attn_blocks |
The number of layers of stacked Multi-Headed Attention layers. Defaults to 6
TYPE:
|
transformer_head_dim |
The number of hidden units in the Multi-Headed Attention layers. Defaults to None and will be same as input_dim.
TYPE:
|
attn_dropout |
Dropout to be applied after Multi headed Attention. Defaults to 0.1
TYPE:
|
add_norm_dropout |
Dropout to be applied in the AddNorm Layer. Defaults to 0.1
TYPE:
|
ff_dropout |
Dropout to be applied in the Positionwise FeedForward Network. Defaults to 0.1
TYPE:
|
ff_hidden_multiplier |
Multiple by which the Positionwise FF layer scales the input. Defaults to 4
TYPE:
|
transformer_activation |
The activation type in the transformer feed forward layers. In addition to the default activation in PyTorch like ReLU, TanH, LeakyReLU, etc. https://pytorch.org/docs/stable/nn.html#non-linear-activations-weighted-sum-nonlinearity, GEGLU, ReGLU and SwiGLU are also implemented(https://arxiv.org/pdf/2002.05202.pdf). Defaults to GEGLU
TYPE:
|
out_ff_layers |
DEPRECATED: Hyphen-separated number of layers and units in the deep MLP. Defaults to 128-64-32
TYPE:
|
out_ff_activation |
DEPRECATED: The activation type in the deep MLP. The default activaion in PyTorch like ReLU, TanH, LeakyReLU, etc. https://pytorch.org/docs/stable/nn.html#non-linear-activations-weighted-sum-nonlinearity. Defaults to ReLU
TYPE:
|
out_ff_dropout |
DEPRECATED: probability of an classification element to be zeroed in the deep MLP. Defaults to 0.0
TYPE:
|
out_ff_initialization |
DEPRECATED: Initialization scheme for the linear layers.
Defaults to
TYPE:
|
task |
Specify whether the problem is regression or classification.
TYPE:
|
head |
The head to be used for the model. Should be one of the heads defined in
TYPE:
|
head_config |
The config as a dict which defines the head. If left empty, will be initialized as default linear head.
TYPE:
|
embedding_dims |
The dimensions of the embedding for each categorical column as a list of tuples (cardinality, embedding_dim). If left empty, will infer using the cardinality of the categorical column using the rule min(50, (x + 1) // 2)
TYPE:
|
embedding_dropout |
Dropout to be applied to the Categorical Embedding. Defaults to 0.1
TYPE:
|
batch_norm_continuous_input |
If True, we will normalize the continuous layer by passing it through a BatchNorm layer.
TYPE:
|
learning_rate |
The learning rate of the model. Defaults to 1e-3.
TYPE:
|
loss |
The loss function to be applied. By Default it is MSELoss for regression and CrossEntropyLoss for classification. Unless you are sure what you are doing, leave it at MSELoss or L1Loss for regression and CrossEntropyLoss for classification
TYPE:
|
metrics |
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in
TYPE:
|
metrics_params |
The parameters to be passed to the metrics function.
TYPE:
|
metrics_prob_input |
Is a mandatory parameter for classification metrics defined in the config. This defines whether the input to the metric function is the probability or the class. Length should be same as the number of metrics. Defaults to None.
TYPE:
|
target_range |
The range in which we should limit the output variable. Currently ignored for multi-target regression. Typically used for Regression problems. If left empty, will not apply any restrictions
TYPE:
|
seed |
The seed for reproducibility. Defaults to 42
TYPE:
|
pytorch_tabular.models.GANDALFConfig
dataclass
Bases: ModelConfig
Gated Adaptive Network for Deep Automated Learning of Features (GANDALF) Config.
PARAMETER | DESCRIPTION |
---|---|
gflu_stages |
Number of layers in the feature abstraction layer. Defaults to 6
TYPE:
|
gflu_dropout |
Dropout rate for the feature abstraction layer. Defaults to 0.0
TYPE:
|
gflu_feature_init_sparsity |
Only valid for t-softmax. The perecentge of features to be selected in each GFLU stage. This is just initialized and during learning it may change. Defaults to 0.3
TYPE:
|
learnable_sparsity |
Only valid for t-softmax. If True, the sparsity parameters
will be learned. If False, the sparsity parameters will be fixed to the initial
values specified in
TYPE:
|
task |
Specify whether the problem is regression or classification.
TYPE:
|
head |
The head to be used for the model. Should be one of the heads defined in
TYPE:
|
head_config |
The config as a dict which defines the head. If left empty, will be initialized as default linear head.
TYPE:
|
embedding_dims |
The dimensions of the embedding for each categorical column as a list of tuples (cardinality, embedding_dim). If left empty, will infer using the cardinality of the categorical column using the rule min(50, (x + 1) // 2)
TYPE:
|
embedding_dropout |
Dropout to be applied to the Categorical Embedding. Defaults to 0.1
TYPE:
|
batch_norm_continuous_input |
If True, we will normalize the continuous layer by passing it through a BatchNorm layer.
TYPE:
|
learning_rate |
The learning rate of the model. Defaults to 1e-3.
TYPE:
|
loss |
The loss function to be applied. By Default it is MSELoss for regression and CrossEntropyLoss for classification. Unless you are sure what you are doing, leave it at MSELoss or L1Loss for regression and CrossEntropyLoss for classification
TYPE:
|
metrics |
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in
TYPE:
|
metrics_params |
The parameters to be passed to the metrics function.
TYPE:
|
metrics_prob_input |
Is a mandatory parameter for classification metrics defined in the config. This defines whether the input to the metric function is the probability or the class. Length should be same as the number of metrics. Defaults to None.
TYPE:
|
target_range |
The range in which we should limit the output variable. Currently ignored for multi-target regression. Typically used for Regression problems. If left empty, will not apply any restrictions
TYPE:
|
seed |
The seed for reproducibility. Defaults to 42
TYPE:
|
pytorch_tabular.models.GatedAdditiveTreeEnsembleConfig
dataclass
Bases: ModelConfig
Gated Additive Tree Ensemble Config.
PARAMETER | DESCRIPTION |
---|---|
gflu_stages |
Number of layers in the feature abstraction layer. Defaults to 6
TYPE:
|
gflu_dropout |
Dropout rate for the feature abstraction layer. Defaults to 0.0
TYPE:
|
tree_depth |
Depth of the tree. Defaults to 5
TYPE:
|
num_trees |
Number of trees to use in the ensemble. Defaults to 20
TYPE:
|
binning_activation |
The binning function to use. Defaults to entmoid. Defaults to sparsemoid.
Choices are: [
TYPE:
|
feature_mask_function |
The feature mask function to use. Defaults to sparsemax. Choices are:
[
TYPE:
|
tree_dropout |
probability of dropout in tree binning transformation. Defaults to 0.0
TYPE:
|
chain_trees |
If True, we will chain the trees together. Synonymous to boosting (chaining trees) or bagging (parallel trees). Defaults to True
TYPE:
|
tree_wise_attention |
If True, we will use tree wise attention to combine trees. Defaults to True
TYPE:
|
tree_wise_attention_dropout |
probability of dropout in the tree wise attention layer. Defaults to 0.0
TYPE:
|
share_head_weights |
If True, we will share the weights between the heads. Defaults to True
TYPE:
|
task |
Specify whether the problem is regression or classification.
TYPE:
|
head |
The head to be used for the model. Should be one of the heads defined in
TYPE:
|
head_config |
The config as a dict which defines the head. If left empty, will be initialized as default linear head.
TYPE:
|
embedding_dims |
The dimensions of the embedding for each categorical column as a list of tuples (cardinality, embedding_dim). If left empty, will infer using the cardinality of the categorical column using the rule min(50, (x + 1) // 2)
TYPE:
|
embedding_dropout |
Dropout to be applied to the Categorical Embedding. Defaults to 0.1
TYPE:
|
batch_norm_continuous_input |
If True, we will normalize the continuous layer by passing it through a BatchNorm layer.
TYPE:
|
learning_rate |
The learning rate of the model. Defaults to 1e-3.
TYPE:
|
loss |
The loss function to be applied. By Default it is MSELoss for regression and CrossEntropyLoss for classification. Unless you are sure what you are doing, leave it at MSELoss or L1Loss for regression and CrossEntropyLoss for classification
TYPE:
|
metrics |
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in
TYPE:
|
metrics_params |
The parameters to be passed to the metrics function.
TYPE:
|
metrics_prob_input |
Is a mandatory parameter for classification metrics defined in the config. This defines whether the input to the metric function is the probability or the class. Length should be same as the number of metrics. Defaults to None.
TYPE:
|
target_range |
The range in which we should limit the output variable. Currently ignored for multi-target regression. Typically used for Regression problems. If left empty, will not apply any restrictions
TYPE:
|
seed |
The seed for reproducibility. Defaults to 42
TYPE:
|
pytorch_tabular.models.MDNConfig
dataclass
Bases: ModelConfig
MDN configuration
PARAMETER | DESCRIPTION |
---|---|
backbone_config_class |
The config class for defining the Backbone. The config class should be
a valid module path from
TYPE:
|
backbone_config_params |
The dict of config parameters for defining the Backbone.
TYPE:
|
task |
Specify whether the problem is regression or classification.
TYPE:
|
head |
TYPE:
|
head_config |
The config for defining the Mixed Density Network Head
TYPE:
|
embedding_dims |
The dimensions of the embedding for each categorical column as a list of tuples (cardinality, embedding_dim). If left empty, will infer using the cardinality of the categorical column using the rule min(50, (x + 1) // 2)
TYPE:
|
embedding_dropout |
Dropout to be applied to the Categorical Embedding. Defaults to 0.1
TYPE:
|
batch_norm_continuous_input |
If True, we will normalize the continuous layer by passing it through a BatchNorm layer.
TYPE:
|
learning_rate |
The learning rate of the model. Defaults to 1e-3.
TYPE:
|
loss |
The loss function to be applied. By Default it is MSELoss for regression and CrossEntropyLoss for classification. Unless you are sure what you are doing, leave it at MSELoss or L1Loss for regression and CrossEntropyLoss for classification
TYPE:
|
metrics |
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in
TYPE:
|
metrics_params |
The parameters to be passed to the metrics function.
TYPE:
|
metrics_prob_input |
Is a mandatory parameter for classification metrics defined in the config. This defines whether the input to the metric function is the probability or the class. Length should be same as the number of metrics. Defaults to None.
TYPE:
|
target_range |
The range in which we should limit the output variable. Currently ignored for multi-target regression. Typically used for Regression problems. If left empty, will not apply any restrictions
TYPE:
|
seed |
The seed for reproducibility. Defaults to 42
TYPE:
|
pytorch_tabular.models.NodeConfig
dataclass
Bases: ModelConfig
Model configuration
PARAMETER | DESCRIPTION |
---|---|
num_layers |
Number of Oblivious Decision Tree Layers in the Dense Architecture
TYPE:
|
num_trees |
Number of Oblivious Decision Trees in each layer
TYPE:
|
additional_tree_output_dim |
The additional output dimensions which is only used to pass through different layers of the architectures. Only the first output_dim outputs will be used for prediction
TYPE:
|
depth |
The depth of the individual Oblivious Decision Trees
TYPE:
|
choice_function |
Generates a sparse probability distribution to be used as feature
weights(aka, soft feature selection). Choices are: [
TYPE:
|
bin_function |
Generates a sparse probability distribution to be used as tree leaf weights.
Choices are: [
TYPE:
|
max_features |
If not None, sets a max limit on the number of features to be carried forward from layer to layer in the Dense Architecture
TYPE:
|
input_dropout |
Dropout to be applied to the inputs between layers of the Dense Architecture
TYPE:
|
initialize_response |
Initializing the response variable in the Oblivious Decision Trees. By
default, it is a standard normal distribution. Choices are: [
TYPE:
|
initialize_selection_logits |
Initializing the feature selector. By default is a uniform
distribution across the features. Choices are: [
TYPE:
|
threshold_init_beta |
Used in the Data-aware initialization of thresholds where the threshold is initialized randomly (with a beta distribution) to feature values in the first batch. It initializes threshold to a q-th quantile of data points. where q ~ Beta(:threshold_init_beta:, :threshold_init_beta:) If this param is set to 1, initial thresholds will have the same distribution as data points If greater than 1 (e.g. 10), thresholds will be closer to median data value If less than 1 (e.g. 0.1), thresholds will approach min/max data values.
TYPE:
|
threshold_init_cutoff |
Used in the Data-aware initialization of scales(used in the scaling ODTs). It is initialized in such a way that all the samples in the first batch belong to the linear region of the entmoid/sparsemoid(bin-selectors) and thereby have non-zero gradients Threshold log-temperatures initializer, in (0, inf) By default(1.0), log-temperatures are initialized in such a way that all bin selectors end up in the linear region of sparse-sigmoid. The temperatures are then scaled by this parameter. Setting this value > 1.0 will result in some margin between data points and sparse-sigmoid cutoff value Setting this value < 1.0 will cause (1 - value) part of data points to end up in flat sparse- sigmoid region For instance, threshold_init_cutoff = 0.9 will set 10% points equal to 0.0 or 1.0 Setting this value > 1.0 will result in a margin between data points and sparse-sigmoid cutoff value All points will be between (0.5 - 0.5 / threshold_init_cutoff) and (0.5 + 0.5 / threshold_init_cutoff)
TYPE:
|
cat_embedding_dropout |
DEPRECATED: Please use
TYPE:
|
embed_categorical |
Flag to embed categorical columns using an Embedding Layer. If turned
off, the categorical columns are encoded using LeaveOneOutEncoder. This is DEPRECATED and will
always be
TYPE:
|
task |
Specify whether the problem is regression or classification.
TYPE:
|
head |
The head to be used for the model. Should be one of the heads defined in
TYPE:
|
head_config |
The config as a dict which defines the head. If left empty, will be initialized as default linear head.
TYPE:
|
embedding_dims |
The dimensions of the embedding for each categorical column as a list of tuples (cardinality, embedding_dim). If left empty, will infer using the cardinality of the categorical column using the rule min(50, (x + 1) // 2)
TYPE:
|
embedding_dropout |
Dropout to be applied to the Categorical Embedding. Defaults to 0.1
TYPE:
|
batch_norm_continuous_input |
If True, we will normalize the continuous layer by passing it through a BatchNorm layer.
TYPE:
|
learning_rate |
The learning rate of the model. Defaults to 1e-3.
TYPE:
|
loss |
The loss function to be applied. By Default it is MSELoss for regression and CrossEntropyLoss for classification. Unless you are sure what you are doing, leave it at MSELoss or L1Loss for regression and CrossEntropyLoss for classification
TYPE:
|
metrics |
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in
TYPE:
|
metrics_params |
The parameters to be passed to the metrics function.
TYPE:
|
metrics_prob_input |
Is a mandatory parameter for classification metrics defined in the config. This defines whether the input to the metric function is the probability or the class. Length should be same as the number of metrics. Defaults to None.
TYPE:
|
target_range |
The range in which we should limit the output variable. Currently ignored for multi-target regression. Typically used for Regression problems. If left empty, will not apply any restrictions
TYPE:
|
seed |
The seed for reproducibility. Defaults to 42
TYPE:
|
pytorch_tabular.models.TabNetModelConfig
dataclass
Bases: ModelConfig
Model configuration
PARAMETER | DESCRIPTION |
---|---|
n_d |
Dimension of the prediction layer (usually between 4 and 64)
TYPE:
|
n_a |
Dimension of the attention layer (usually between 4 and 64)
TYPE:
|
n_steps |
Number of sucessive steps in the newtork (usually betwenn 3 and 10)
TYPE:
|
gamma |
Float above 1, scaling factor for attention updates (usually betwenn 1.0 to 2.0)
TYPE:
|
n_independent |
Number of independent GLU layer in each GLU block (default 2)
TYPE:
|
n_shared |
Number of independent GLU layer in each GLU block (default 2)
TYPE:
|
virtual_batch_size |
Batch size for Ghost Batch Normalization
TYPE:
|
mask_type |
Either 'sparsemax' or 'entmax' : this is the masking function to use. Choices are:
[
TYPE:
|
task |
Specify whether the problem is regression or classification.
TYPE:
|
head |
The head to be used for the model. Should be one of the heads defined in
TYPE:
|
head_config |
The config as a dict which defines the head. If left empty, will be initialized as default linear head.
TYPE:
|
embedding_dims |
The dimensions of the embedding for each categorical column as a list of tuples (cardinality, embedding_dim). If left empty, will infer using the cardinality of the categorical column using the rule min(50, (x + 1) // 2)
TYPE:
|
embedding_dropout |
Dropout to be applied to the Categorical Embedding. Defaults to 0.1
TYPE:
|
batch_norm_continuous_input |
If True, we will normalize the continuous layer by passing it through a BatchNorm layer.
TYPE:
|
learning_rate |
The learning rate of the model. Defaults to 1e-3.
TYPE:
|
loss |
The loss function to be applied. By Default it is MSELoss for regression and CrossEntropyLoss for classification. Unless you are sure what you are doing, leave it at MSELoss or L1Loss for regression and CrossEntropyLoss for classification
TYPE:
|
metrics |
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in
TYPE:
|
metrics_params |
The parameters to be passed to the metrics function.
TYPE:
|
metrics_prob_input |
Is a mandatory parameter for classification metrics defined in the config. This defines whether the input to the metric function is the probability or the class. Length should be same as the number of metrics. Defaults to None.
TYPE:
|
target_range |
The range in which we should limit the output variable. Currently ignored for multi-target regression. Typically used for Regression problems. If left empty, will not apply any restrictions
TYPE:
|
seed |
The seed for reproducibility. Defaults to 42
TYPE:
|
pytorch_tabular.models.TabTransformerConfig
dataclass
Bases: ModelConfig
Tab Transformer configuration
PARAMETER | DESCRIPTION |
---|---|
input_embed_dim |
The embedding dimension for the input categorical features. Defaults to 32
TYPE:
|
embedding_initialization |
Initialization scheme for the embedding layers. Defaults
to
TYPE:
|
embedding_bias |
Flag to turn on Embedding Bias. Defaults to False
TYPE:
|
share_embedding |
The flag turns on shared embeddings in the input embedding process. The key idea here is to have an embedding for the feature as a whole along with embeddings of each unique values of that column. For more details refer to Appendix A of the TabTransformer paper. Defaults to False
TYPE:
|
share_embedding_strategy |
There are two strategies in adding shared embeddings. 1.
TYPE:
|
shared_embedding_fraction |
Fraction of the input_embed_dim to be reserved by the shared embedding. Should be less than one. Defaults to 0.25
TYPE:
|
num_heads |
The number of heads in the Multi-Headed Attention layer. Defaults to 8
TYPE:
|
num_attn_blocks |
The number of layers of stacked Multi-Headed Attention layers. Defaults to 6
TYPE:
|
transformer_head_dim |
The number of hidden units in the Multi-Headed Attention layers. Defaults to None and will be same as input_dim.
TYPE:
|
attn_dropout |
Dropout to be applied after Multi headed Attention. Defaults to 0.1
TYPE:
|
add_norm_dropout |
Dropout to be applied in the AddNorm Layer. Defaults to 0.1
TYPE:
|
ff_dropout |
Dropout to be applied in the Positionwise FeedForward Network. Defaults to 0.1
TYPE:
|
ff_hidden_multiplier |
Multiple by which the Positionwise FF layer scales the input. Defaults to 4
TYPE:
|
transformer_activation |
The activation type in the transformer feed forward layers. In addition to the default activation in PyTorch like ReLU, TanH, LeakyReLU, etc. https://pytorch.org/docs/stable/nn.html#non-linear-activations-weighted-sum-nonlinearity, GEGLU, ReGLU and SwiGLU are also implemented(https://arxiv.org/pdf/2002.05202.pdf). Defaults to GEGLU
TYPE:
|
out_ff_layers |
DEPRECATED: Hyphen-separated number of layers and units in the deep MLP. Defaults to 128-64-32
TYPE:
|
out_ff_activation |
DEPRECATED: The activation type in the deep MLP. The default activaion in PyTorch like ReLU, TanH, LeakyReLU, etc. https://pytorch.org/docs/stable/nn.html#non- linear-activations-weighted-sum-nonlinearity. Defaults to ReLU
TYPE:
|
out_ff_dropout |
DEPRECATED: probability of an classification element to be zeroed in the deep MLP. Defaults to 0.0
TYPE:
|
out_ff_initialization |
DEPRECATED: Initialization scheme for the linear layers.
Defaults to
TYPE:
|
task |
Specify whether the problem is regression or classification.
TYPE:
|
head |
The head to be used for the model. Should be one of the heads defined in
TYPE:
|
head_config |
The config as a dict which defines the head. If left empty, will be initialized as default linear head.
TYPE:
|
embedding_dims |
The dimensions of the embedding for each categorical column as a list of tuples (cardinality, embedding_dim). If left empty, will infer using the cardinality of the categorical column using the rule min(50, (x + 1) // 2)
TYPE:
|
embedding_dropout |
Dropout to be applied to the Categorical Embedding. Defaults to 0.1
TYPE:
|
batch_norm_continuous_input |
If True, we will normalize the continuous layer by passing it through a BatchNorm layer.
TYPE:
|
learning_rate |
The learning rate of the model. Defaults to 1e-3.
TYPE:
|
loss |
The loss function to be applied. By Default it is MSELoss for regression and CrossEntropyLoss for classification. Unless you are sure what you are doing, leave it at MSELoss or L1Loss for regression and CrossEntropyLoss for classification
TYPE:
|
metrics |
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in
TYPE:
|
metrics_params |
The parameters to be passed to the metrics function.
TYPE:
|
metrics_prob_input |
Is a mandatory parameter for classification metrics defined in the config. This defines whether the input to the metric function is the probability or the class. Length should be same as the number of metrics. Defaults to None.
TYPE:
|
target_range |
The range in which we should limit the output variable. Currently ignored for multi-target regression. Typically used for Regression problems. If left empty, will not apply any restrictions
TYPE:
|
seed |
The seed for reproducibility. Defaults to 42
TYPE:
|
pytorch_tabular.config.ModelConfig
dataclass
Base Model configuration
PARAMETER | DESCRIPTION |
---|---|
task |
Specify whether the problem is regression or classification.
TYPE:
|
head |
The head to be used for the model. Should be one of the heads defined in
TYPE:
|
head_config |
The config as a dict which defines the head. If left empty, will be initialized as default linear head.
TYPE:
|
embedding_dims |
The dimensions of the embedding for each categorical column as a list of tuples (cardinality, embedding_dim). If left empty, will infer using the cardinality of the categorical column using the rule min(50, (x + 1) // 2)
TYPE:
|
embedding_dropout |
Dropout to be applied to the Categorical Embedding. Defaults to 0.0
TYPE:
|
batch_norm_continuous_input |
If True, we will normalize the continuous layer by passing it through a BatchNorm layer.
TYPE:
|
learning_rate |
The learning rate of the model. Defaults to 1e-3.
TYPE:
|
loss |
The loss function to be applied. By Default it is MSELoss for regression and CrossEntropyLoss for classification. Unless you are sure what you are doing, leave it at MSELoss or L1Loss for regression and CrossEntropyLoss for classification
TYPE:
|
metrics |
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in
TYPE:
|
metrics_prob_input |
Is a mandatory parameter for classification metrics defined in the config. This defines whether the input to the metric function is the probability or the class. Length should be same as the number of metrics. Defaults to None.
TYPE:
|
metrics_params |
The parameters to be passed to the metrics function.
TYPE:
|
target_range |
The range in which we should limit the output variable. Currently ignored for multi-target regression. Typically used for Regression problems. If left empty, will not apply any restrictions
TYPE:
|
seed |
The seed for reproducibility. Defaults to 42
TYPE:
|
Model Classes
pytorch_tabular.models.AutoIntModel(config, **kwargs)
pytorch_tabular.models.CategoryEmbeddingModel(config, **kwargs)
pytorch_tabular.models.FTTransformerModel(config, **kwargs)
pytorch_tabular.models.GANDALFModel(config, **kwargs)
pytorch_tabular.models.GatedAdditiveTreeEnsembleModel(config, **kwargs)
pytorch_tabular.models.MDNModel(config, **kwargs)
Bases: BaseModel
Source code in src/pytorch_tabular/models/mixture_density/mdn.py
pytorch_tabular.models.NODEModel(config, **kwargs)
Bases: BaseModel
Source code in src/pytorch_tabular/models/node/node_model.py
data_aware_initialization(datamodule)
Performs data-aware initialization for NODE.
Source code in src/pytorch_tabular/models/node/node_model.py
pytorch_tabular.models.TabNetModel(config, **kwargs)
pytorch_tabular.models.TabTransformerModel(config, **kwargs)
Base Model Class
pytorch_tabular.models.BaseModel(config, custom_loss=None, custom_metrics=None, custom_metrics_prob_inputs=None, custom_optimizer=None, custom_optimizer_params={}, **kwargs)
Bases: pl.LightningModule
Base Model for PyTorch Tabular.
PARAMETER | DESCRIPTION |
---|---|
config |
The configuration for the model.
TYPE:
|
custom_loss |
A custom loss function. Defaults to None.
TYPE:
|
custom_metrics |
A list of custom metrics. Defaults to None.
TYPE:
|
custom_metrics_prob_inputs |
A list of boolean values indicating whether the metric requires probability inputs. Defaults to None.
TYPE:
|
custom_optimizer |
A custom optimizer. Defaults to None.
TYPE:
|
custom_optimizer_params |
A dictionary of custom optimizer parameters. Defaults to {}.
TYPE:
|
kwargs |
Additional keyword arguments.
TYPE:
|
Source code in src/pytorch_tabular/models/base_model.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
apply_output_sigmoid_scaling(y_hat)
Applies sigmoid scaling to the output of the model if the task is regression and the target range is defined.
PARAMETER | DESCRIPTION |
---|---|
y_hat |
The output of the model
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
torch.Tensor
|
torch.Tensor: The output of the model with sigmoid scaling applied |
Source code in src/pytorch_tabular/models/base_model.py
calculate_loss(output, y, tag)
Calculates the loss for the model.
PARAMETER | DESCRIPTION |
---|---|
output |
The output dictionary from the model
TYPE:
|
y |
The target tensor
TYPE:
|
tag |
The tag to use for logging
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
torch.Tensor
|
torch.Tensor: The loss value |
Source code in src/pytorch_tabular/models/base_model.py
calculate_metrics(y, y_hat, tag)
Calculates the metrics for the model.
PARAMETER | DESCRIPTION |
---|---|
y |
The target tensor
TYPE:
|
y_hat |
The predicted tensor
TYPE:
|
tag |
The tag to use for logging
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
List[torch.Tensor]
|
List[torch.Tensor]: The list of metric values |
Source code in src/pytorch_tabular/models/base_model.py
compute_head(backbone_features)
Computes the head of the model.
PARAMETER | DESCRIPTION |
---|---|
backbone_features |
The backbone features
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Dict[str, Any]
|
The output of the model |
Source code in src/pytorch_tabular/models/base_model.py
data_aware_initialization(datamodule)
extract_embedding()
Extracts the embedding of the model.
This is used in CategoricalEmbeddingTransformer
Source code in src/pytorch_tabular/models/base_model.py
feature_importance()
Returns a dataframe with feature importance for the model.
Source code in src/pytorch_tabular/models/base_model.py
forward(x)
The forward pass of the model.
PARAMETER | DESCRIPTION |
---|---|
x |
The input of the model with 'continuous' and 'categorical' keys
TYPE:
|
Source code in src/pytorch_tabular/models/base_model.py
pack_output(y_hat, backbone_features)
Packs the output of the model.
PARAMETER | DESCRIPTION |
---|---|
y_hat |
The output of the model
TYPE:
|
backbone_features |
The backbone features
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Dict[str, Any]
|
The packed output of the model |
Source code in src/pytorch_tabular/models/base_model.py
predict(x, ret_model_output=False)
Predicts the output of the model.
PARAMETER | DESCRIPTION |
---|---|
x |
The input of the model with 'continuous' and 'categorical' keys
TYPE:
|
ret_model_output |
If True, the method returns the output of the model
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Union[torch.Tensor, Tuple[torch.Tensor, Dict]]
|
The output of the model |