Supervised Models
Configuration Classes¶
Bases: ModelConfig
AutomaticFeatureInteraction configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attn_embed_dim |
int
|
The number of hidden units in the Multi-Headed Attention layers. Defaults to 32 |
32
|
num_heads |
int
|
The number of heads in the Multi-Headed Attention layer. Defaults to 2 |
2
|
num_attn_blocks |
int
|
The number of layers of stacked Multi-Headed Attention layers. Defaults to 3 |
3
|
attn_dropouts |
float
|
Dropout between layers of Multi-Headed Attention Layers. Defaults to 0.0 |
0.0
|
has_residuals |
bool
|
Flag to have a residual connect from embedded output to attention layer output. Defaults to True |
True
|
embedding_dim |
int
|
The dimensions of the embedding for continuous and categorical columns. Defaults to 16 |
16
|
embedding_initialization |
Optional[str]
|
Initialization scheme for the embedding layers. Defaults
to |
'kaiming_uniform'
|
embedding_bias |
bool
|
Flag to turn on Embedding Bias. Defaults to True |
True
|
share_embedding |
bool
|
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 |
False
|
share_embedding_strategy |
Optional[str]
|
There are two strategies in adding shared embeddings. 1.
|
'fraction'
|
shared_embedding_fraction |
float
|
Fraction of the input_embed_dim to be reserved by the shared embedding. Should be less than one. Defaults to 0.25 |
0.25
|
deep_layers |
bool
|
Flag to enable a deep MLP layer before the Multi-Headed Attention layer. Defaults to False |
False
|
layers |
str
|
Hyphen-separated number of layers and units in the deep MLP. Defaults to 128-64-32 |
'128-64-32'
|
activation |
str
|
The activation type in the deep MLP. The default activation in PyTorch like ReLU, TanH, LeakyReLU, etc. https://pytorch.org/docs/stable/nn.html#non-linear-activations-weighted-sum-nonlinearity. Defaults to ReLU |
'ReLU'
|
use_batch_norm |
bool
|
Flag to include a BatchNorm layer after each Linear Layer+DropOut in the deep MLP. Defaults to False |
False
|
initialization |
str
|
Initialization scheme for the linear layers in the deep MLP. Defaults to
|
'kaiming'
|
dropout |
float
|
Probability of an element to be zeroed in the deep MLP. Defaults to 0.0 |
0.0
|
attention_pooling |
bool
|
If True, will combine the attention outputs of each block for final prediction. Defaults to False |
False
|
task |
str
|
Specify whether the problem is regression or classification. |
required |
head |
Optional[str]
|
The head to be used for the model. Should be one of the heads defined in
|
'LinearHead'
|
head_config |
Optional[Dict]
|
The config as a dict which defines the head. If left empty, will be initialized as default linear head. |
lambda: {'layers': ''}()
|
embedding_dims |
Optional[List]
|
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) |
None
|
embedding_dropout |
float
|
Dropout to be applied to the Categorical Embedding. Defaults to 0.0 |
0.0
|
batch_norm_continuous_input |
bool
|
If True, we will normalize the continuous layer by passing it through a BatchNorm layer. |
True
|
learning_rate |
float
|
The learning rate of the model. Defaults to 1e-3. |
0.001
|
loss |
Optional[str]
|
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 |
None
|
metrics |
Optional[List[str]]
|
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in |
None
|
metrics_params |
Optional[List]
|
The parameters to be passed to the metrics function |
None
|
metrics_prob_input |
Optional[List]
|
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. |
None
|
target_range |
Optional[List]
|
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 |
None
|
seed |
int
|
The seed for reproducibility. Defaults to 42 |
42
|
Source code in src/pytorch_tabular/models/autoint/config.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
|
Bases: ModelConfig
CategoryEmbeddingModel configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layers |
str
|
DEPRECATED: Hyphen-separated number of layers and units in the classification head. E.g. 32-64-32. Defaults to 128-64-32 |
'128-64-32'
|
activation |
str
|
DEPRECATED: The activation type in the classification head. The default activation in PyTorch like ReLU, TanH, LeakyReLU, etc. https://pytorch.org/docs/stable/nn.html#non-linear-activations-weighted-sum-nonlinearity. Defaults to ReLU |
'ReLU'
|
use_batch_norm |
bool
|
DEPRECATED: Flag to include a BatchNorm layer after each Linear Layer+DropOut. Defaults to False |
False
|
initialization |
str
|
DEPRECATED: Initialization scheme for the linear layers. Defaults to |
'kaiming'
|
dropout |
float
|
DEPRECATED: probability of a classification element to be zeroed. This is added to each linear layer. Defaults to 0.0 |
0.0
|
task |
str
|
Specify whether the problem is regression or classification. |
required |
head |
Optional[str]
|
The head to be used for the model. Should be one of the heads defined in
|
'LinearHead'
|
head_config |
Optional[Dict]
|
The config as a dict which defines the head. If left empty, will be initialized as default linear head. |
lambda: {'layers': ''}()
|
embedding_dims |
Optional[List]
|
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) |
None
|
embedding_dropout |
float
|
Dropout to be applied to the Categorical Embedding. Defaults to 0.0 |
0.0
|
batch_norm_continuous_input |
bool
|
If True, we will normalize the continuous layer by passing it through a BatchNorm layer. |
True
|
learning_rate |
float
|
The learning rate of the model. Defaults to 1e-3. |
0.001
|
loss |
Optional[str]
|
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 |
None
|
metrics |
Optional[List[str]]
|
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in |
None
|
metrics_params |
Optional[List]
|
The parameters to be passed to the metrics function. |
None
|
metrics_prob_input |
Optional[List]
|
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. |
None
|
target_range |
Optional[List]
|
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 |
None
|
seed |
int
|
The seed for reproducibility. Defaults to 42 |
42
|
Source code in src/pytorch_tabular/models/category_embedding/config.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 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 |
|
Bases: ModelConfig
DANet configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_layers |
int
|
Number of Blocks in the DANet. 8, 20, 32 are configurations the paper evaluated. Defaults to 8 |
8
|
abstlay_dim_1 |
int
|
The dimension for the intermediate output in the first ABSTLAY layer in a Block. Defaults to 32 |
32
|
abstlay_dim_2 |
int
|
The dimension for the intermediate output in the second ABSTLAY layer in a Block. Defaults to 64 |
None
|
k |
int
|
The number of feature groups in the ABSTLAY layer. Defaults to 5 |
5
|
dropout_rate |
float
|
Dropout to be applied in the Block. Defaults to 0.1 |
0.1
|
task |
str
|
Specify whether the problem is regression or classification. |
required |
head |
Optional[str]
|
The head to be used for the model. Should be one of the heads defined in
|
'LinearHead'
|
head_config |
Optional[Dict]
|
The config as a dict which defines the head. If left empty, will be initialized as default linear head. |
lambda: {'layers': ''}()
|
embedding_dims |
Optional[List]
|
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) |
None
|
embedding_dropout |
float
|
Dropout to be applied to the Categorical Embedding. Defaults to 0.0 |
0.0
|
batch_norm_continuous_input |
bool
|
If True, we will normalize the continuous layer by passing it through a BatchNorm layer. |
True
|
learning_rate |
float
|
The learning rate of the model. Defaults to 1e-3. |
0.001
|
loss |
Optional[str]
|
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 |
None
|
metrics |
Optional[List[str]]
|
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in |
None
|
metrics_params |
Optional[List]
|
The parameters to be passed to the metrics function. |
None
|
metrics_prob_input |
Optional[List]
|
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. |
None
|
target_range |
Optional[List]
|
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 |
None
|
seed |
int
|
The seed for reproducibility. Defaults to 42 |
42
|
Source code in src/pytorch_tabular/models/danet/config.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 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 |
|
Bases: ModelConfig
Tab Transformer configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_embed_dim |
int
|
The embedding dimension for the input categorical features. Defaults to 32 |
32
|
embedding_initialization |
Optional[str]
|
Initialization scheme for the embedding layers. Defaults
to |
'kaiming_uniform'
|
embedding_bias |
bool
|
Flag to turn on Embedding Bias. Defaults to True |
True
|
share_embedding |
bool
|
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 |
False
|
share_embedding_strategy |
Optional[str]
|
There are two strategies in adding shared embeddings. 1.
|
'fraction'
|
shared_embedding_fraction |
float
|
Fraction of the input_embed_dim to be reserved by the shared embedding. Should be less than one. Defaults to 0.25 |
0.25
|
attn_feature_importance |
bool
|
If you are facing memory issues, you can turn off feature importance which will not save the attention weights. Defaults to True |
True
|
num_heads |
int
|
The number of heads in the Multi-Headed Attention layer. Defaults to 8 |
8
|
num_attn_blocks |
int
|
The number of layers of stacked Multi-Headed Attention layers. Defaults to 6 |
6
|
transformer_head_dim |
Optional[int]
|
The number of hidden units in the Multi-Headed Attention layers. Defaults to None and will be same as input_dim. |
None
|
attn_dropout |
float
|
Dropout to be applied after Multi headed Attention. Defaults to 0.1 |
0.1
|
add_norm_dropout |
float
|
Dropout to be applied in the AddNorm Layer. Defaults to 0.1 |
0.1
|
ff_dropout |
float
|
Dropout to be applied in the Positionwise FeedForward Network. Defaults to 0.1 |
0.1
|
ff_hidden_multiplier |
int
|
Multiple by which the Positionwise FF layer scales the input. Defaults to 4 |
4
|
transformer_activation |
str
|
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 |
'GEGLU'
|
task |
str
|
Specify whether the problem is regression or classification. |
required |
head |
Optional[str]
|
The head to be used for the model. Should be one of the heads defined in
|
'LinearHead'
|
head_config |
Optional[Dict]
|
The config as a dict which defines the head. If left empty, will be initialized as default linear head. |
lambda: {'layers': ''}()
|
embedding_dims |
Optional[List]
|
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) |
None
|
embedding_dropout |
float
|
Dropout to be applied to the Categorical Embedding. Defaults to 0.0 |
0.0
|
batch_norm_continuous_input |
bool
|
If True, we will normalize the continuous layer by passing it through a BatchNorm layer. |
True
|
learning_rate |
float
|
The learning rate of the model. Defaults to 1e-3. |
0.001
|
loss |
Optional[str]
|
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 |
None
|
metrics |
Optional[List[str]]
|
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in |
None
|
metrics_params |
Optional[List]
|
The parameters to be passed to the metrics function. |
None
|
metrics_prob_input |
Optional[List]
|
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. |
None
|
target_range |
Optional[List]
|
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 |
None
|
seed |
int
|
The seed for reproducibility. Defaults to 42 |
42
|
Source code in src/pytorch_tabular/models/ft_transformer/config.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
|
Bases: ModelConfig
Gated Adaptive Network for Deep Automated Learning of Features (GANDALF) Config.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gflu_stages |
int
|
Number of layers in the feature abstraction layer. Defaults to 6 |
6
|
gflu_dropout |
float
|
Dropout rate for the feature abstraction layer. Defaults to 0.0 |
0.0
|
gflu_feature_init_sparsity |
float
|
Only valid for t-softmax. The percentage of features to be selected in each GFLU stage. This is just initialized and during learning it may change. Defaults to 0.3 |
0.3
|
learnable_sparsity |
bool
|
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 |
True
|
task |
str
|
Specify whether the problem is regression or classification. |
required |
head |
Optional[str]
|
The head to be used for the model. Should be one of the heads defined in
|
'LinearHead'
|
head_config |
Optional[Dict]
|
The config as a dict which defines the head. If left empty, will be initialized as default linear head. |
lambda: {'layers': ''}()
|
embedding_dims |
Optional[List]
|
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) |
None
|
embedding_dropout |
float
|
Dropout to be applied to the Categorical Embedding. Defaults to 0.0 |
0.0
|
batch_norm_continuous_input |
bool
|
If True, we will normalize the continuous layer by passing it through a BatchNorm layer. |
True
|
learning_rate |
float
|
The learning rate of the model. Defaults to 1e-3. |
0.001
|
loss |
Optional[str]
|
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 |
None
|
metrics |
Optional[List[str]]
|
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in |
None
|
metrics_params |
Optional[List]
|
The parameters to be passed to the metrics function. |
None
|
metrics_prob_input |
Optional[List]
|
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. |
None
|
target_range |
Optional[List]
|
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 |
None
|
seed |
int
|
The seed for reproducibility. Defaults to 42 |
42
|
Source code in src/pytorch_tabular/models/gandalf/config.py
Bases: ModelConfig
Gated Additive Tree Ensemble configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gflu_stages |
int
|
Number of layers in the feature abstraction layer. Defaults to 6 |
6
|
gflu_dropout |
float
|
Dropout rate for the feature abstraction layer. Defaults to 0.0 |
0.0
|
tree_depth |
int
|
Depth of the tree. Defaults to 5 |
4
|
num_trees |
int
|
Number of trees to use in the ensemble. Defaults to 20 |
10
|
binning_activation |
str
|
The binning function to use. Defaults to entmoid. Defaults to sparsemoid.
Choices are: [ |
'sparsemoid'
|
feature_mask_function |
str
|
The feature mask function to use. Defaults to sparsemax. Choices are:
[ |
't-softmax'
|
tree_dropout |
float
|
probability of dropout in tree binning transformation. Defaults to 0.0 |
0.0
|
chain_trees |
bool
|
If True, we will chain the trees together. Synonymous to boosting (chaining trees) or bagging (parallel trees). Defaults to True |
True
|
tree_wise_attention |
bool
|
If True, we will use tree wise attention to combine trees. Defaults to True |
True
|
tree_wise_attention_dropout |
float
|
probability of dropout in the tree wise attention layer. Defaults to 0.0 |
0.0
|
share_head_weights |
bool
|
If True, we will share the weights between the heads. Defaults to True |
True
|
task |
str
|
Specify whether the problem is regression or classification. |
required |
head |
Optional[str]
|
The head to be used for the model. Should be one of the heads defined in
|
'LinearHead'
|
head_config |
Optional[Dict]
|
The config as a dict which defines the head. If left empty, will be initialized as default linear head. |
lambda: {'layers': ''}()
|
embedding_dims |
Optional[List]
|
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) |
None
|
embedding_dropout |
float
|
Dropout to be applied to the Categorical Embedding. Defaults to 0.0 |
0.0
|
batch_norm_continuous_input |
bool
|
If True, we will normalize the continuous layer by passing it through a BatchNorm layer. |
True
|
learning_rate |
float
|
The learning rate of the model. Defaults to 1e-3. |
0.001
|
loss |
Optional[str]
|
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 |
None
|
metrics |
Optional[List[str]]
|
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in |
None
|
metrics_params |
Optional[List]
|
The parameters to be passed to the metrics function. |
None
|
metrics_prob_input |
Optional[List]
|
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. |
None
|
target_range |
Optional[List]
|
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 |
None
|
seed |
int
|
The seed for reproducibility. Defaults to 42 |
42
|
Source code in src/pytorch_tabular/models/gate/config.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
Bases: ModelConfig
MDN configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
backbone_config_class |
str
|
The config class for defining the Backbone. The config class should be
a valid module path from |
None
|
backbone_config_params |
Dict
|
The dict of config parameters for defining the Backbone. |
None
|
task |
str
|
Specify whether the problem is regression or classification. |
required |
head |
str
|
|
'LinearHead'
|
head_config |
Dict
|
The config for defining the Mixed Density Network Head |
None
|
embedding_dims |
Optional[List]
|
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) |
None
|
embedding_dropout |
float
|
Dropout to be applied to the Categorical Embedding. Defaults to 0.0 |
0.0
|
batch_norm_continuous_input |
bool
|
If True, we will normalize the continuous layer by passing it through a BatchNorm layer. |
True
|
learning_rate |
float
|
The learning rate of the model. Defaults to 1e-3. |
0.001
|
loss |
Optional[str]
|
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 |
None
|
metrics |
Optional[List[str]]
|
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in |
None
|
metrics_params |
Optional[List]
|
The parameters to be passed to the metrics function. |
None
|
metrics_prob_input |
Optional[List]
|
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. |
None
|
target_range |
Optional[List]
|
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 |
None
|
seed |
int
|
The seed for reproducibility. Defaults to 42 |
42
|
Source code in src/pytorch_tabular/models/mixture_density/config.py
Bases: ModelConfig
Neural Oblivious Decision Ensembles for Deep Learning on Tabular Data configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_layers |
int
|
Number of Oblivious Decision Tree Layers in the Dense Architecture |
1
|
num_trees |
int
|
Number of Oblivious Decision Trees in each layer |
2048
|
additional_tree_output_dim |
int
|
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 |
3
|
depth |
int
|
The depth of the individual Oblivious Decision Trees |
6
|
choice_function |
str
|
Generates a sparse probability distribution to be used as feature
weights(aka, soft feature selection). Choices are: [ |
'entmax15'
|
bin_function |
str
|
Generates a sparse probability distribution to be used as tree leaf weights.
Choices are: [ |
'entmoid15'
|
max_features |
Optional[int]
|
If not None, sets a max limit on the number of features to be carried forward from layer to layer in the Dense Architecture |
None
|
input_dropout |
float
|
Dropout to be applied to the inputs between layers of the Dense Architecture |
0.0
|
initialize_response |
str
|
Initializing the response variable in the Oblivious Decision Trees. By
default, it is a standard normal distribution. Choices are: [ |
'normal'
|
initialize_selection_logits |
str
|
Initializing the feature selector. By default, is a uniform
distribution across the features. Choices are: [ |
'uniform'
|
threshold_init_beta |
float
|
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. |
1.0
|
threshold_init_cutoff |
float
|
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) |
1.0
|
task |
str
|
Specify whether the problem is regression or classification. |
required |
head |
Optional[str]
|
The head to be used for the model. Should be one of the heads defined in
|
None
|
head_config |
Optional[Dict]
|
The config as a dict which defines the head. If left empty, will be initialized as default linear head. |
lambda: {'layers': ''}()
|
embedding_dims |
Optional[List]
|
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) |
None
|
embedding_dropout |
float
|
Dropout to be applied to the Categorical Embedding. Defaults to 0.0 |
0.0
|
batch_norm_continuous_input |
bool
|
If True, we will normalize the continuous layer by passing it through a BatchNorm layer. |
True
|
learning_rate |
float
|
The learning rate of the model. Defaults to 1e-3. |
0.001
|
loss |
Optional[str]
|
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 |
None
|
metrics |
Optional[List[str]]
|
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in |
None
|
metrics_params |
Optional[List]
|
The parameters to be passed to the metrics function. |
None
|
metrics_prob_input |
Optional[List]
|
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. |
None
|
target_range |
Optional[List]
|
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 |
None
|
seed |
int
|
The seed for reproducibility. Defaults to 42 |
42
|
Source code in src/pytorch_tabular/models/node/config.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
Bases: ModelConfig
TabNet: Attentive Interpretable Tabular Learning configuration
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_d |
int
|
Dimension of the prediction layer (usually between 4 and 64) |
8
|
n_a |
int
|
Dimension of the attention layer (usually between 4 and 64) |
8
|
n_steps |
int
|
Number of successive steps in the network (usually between 3 and 10) |
3
|
gamma |
float
|
Float above 1, scaling factor for attention updates (usually between 1.0 to 2.0) |
1.3
|
n_independent |
int
|
Number of independent GLU layer in each GLU block (default 2) |
2
|
n_shared |
int
|
Number of independent GLU layer in each GLU block (default 2) |
2
|
virtual_batch_size |
int
|
Batch size for Ghost Batch Normalization |
128
|
mask_type |
str
|
Either 'sparsemax' or 'entmax' : this is the masking function to use. Choices are:
[ |
'sparsemax'
|
task |
str
|
Specify whether the problem is regression or classification. |
required |
head |
Optional[str]
|
The head to be used for the model. Should be one of the heads defined in
|
'LinearHead'
|
head_config |
Optional[Dict]
|
The config as a dict which defines the head. If left empty, will be initialized as default linear head. |
lambda: {'layers': ''}()
|
embedding_dims |
Optional[List]
|
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) |
None
|
embedding_dropout |
float
|
Dropout to be applied to the Categorical Embedding. Defaults to 0.0 |
0.0
|
batch_norm_continuous_input |
bool
|
If True, we will normalize the continuous layer by passing it through a BatchNorm layer. |
True
|
learning_rate |
float
|
The learning rate of the model. Defaults to 1e-3. |
0.001
|
loss |
Optional[str]
|
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 |
None
|
metrics |
Optional[List[str]]
|
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in |
None
|
metrics_params |
Optional[List]
|
The parameters to be passed to the metrics function. |
None
|
metrics_prob_input |
Optional[List]
|
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. |
None
|
target_range |
Optional[List]
|
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 |
None
|
seed |
int
|
The seed for reproducibility. Defaults to 42 |
42
|
Source code in src/pytorch_tabular/models/tabnet/config.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 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 |
|
Bases: ModelConfig
Tab Transformer configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_embed_dim |
int
|
The embedding dimension for the input categorical features. Defaults to 32 |
32
|
embedding_initialization |
Optional[str]
|
Initialization scheme for the embedding layers. Defaults
to |
'kaiming_uniform'
|
embedding_bias |
bool
|
Flag to turn on Embedding Bias. Defaults to False |
False
|
share_embedding |
bool
|
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 |
False
|
share_embedding_strategy |
Optional[str]
|
There are two strategies in adding shared embeddings. 1.
|
'fraction'
|
shared_embedding_fraction |
float
|
Fraction of the input_embed_dim to be reserved by the shared embedding. Should be less than one. Defaults to 0.25 |
0.25
|
num_heads |
int
|
The number of heads in the Multi-Headed Attention layer. Defaults to 8 |
8
|
num_attn_blocks |
int
|
The number of layers of stacked Multi-Headed Attention layers. Defaults to 6 |
6
|
transformer_head_dim |
Optional[int]
|
The number of hidden units in the Multi-Headed Attention layers. Defaults to None and will be same as input_dim. |
None
|
attn_dropout |
float
|
Dropout to be applied after Multi headed Attention. Defaults to 0.1 |
0.1
|
add_norm_dropout |
float
|
Dropout to be applied in the AddNorm Layer. Defaults to 0.1 |
0.1
|
ff_dropout |
float
|
Dropout to be applied in the Positionwise FeedForward Network. Defaults to 0.1 |
0.1
|
ff_hidden_multiplier |
int
|
Multiple by which the Positionwise FF layer scales the input. Defaults to 4 |
4
|
transformer_activation |
str
|
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 |
'GEGLU'
|
task |
str
|
Specify whether the problem is regression or classification. |
required |
head |
Optional[str]
|
The head to be used for the model. Should be one of the heads defined in
|
'LinearHead'
|
head_config |
Optional[Dict]
|
The config as a dict which defines the head. If left empty, will be initialized as default linear head. |
lambda: {'layers': ''}()
|
embedding_dims |
Optional[List]
|
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) |
None
|
embedding_dropout |
float
|
Dropout to be applied to the Categorical Embedding. Defaults to 0.0 |
0.0
|
batch_norm_continuous_input |
bool
|
If True, we will normalize the continuous layer by passing it through a BatchNorm layer. |
True
|
learning_rate |
float
|
The learning rate of the model. Defaults to 1e-3. |
0.001
|
loss |
Optional[str]
|
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 |
None
|
metrics |
Optional[List[str]]
|
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in |
None
|
metrics_params |
Optional[List]
|
The parameters to be passed to the metrics function. |
None
|
metrics_prob_input |
Optional[List]
|
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. |
None
|
target_range |
Optional[List]
|
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 |
None
|
seed |
int
|
The seed for reproducibility. Defaults to 42 |
42
|
Source code in src/pytorch_tabular/models/tab_transformer/config.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
Base Model configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task |
str
|
Specify whether the problem is regression or classification. |
required |
head |
Optional[str]
|
The head to be used for the model. Should be one of the heads defined in
|
'LinearHead'
|
head_config |
Optional[Dict]
|
The config as a dict which defines the head. If left empty, will be initialized as default linear head. |
lambda: {'layers': ''}()
|
embedding_dims |
Optional[List]
|
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) |
None
|
embedding_dropout |
float
|
Dropout to be applied to the Categorical Embedding. Defaults to 0.0 |
0.0
|
batch_norm_continuous_input |
bool
|
If True, we will normalize the continuous layer by passing it through a BatchNorm layer. |
True
|
virtual_batch_size |
Optional[int]
|
If not None, all BatchNorms will be converted to GhostBatchNorm's with the specified virtual batch size. Defaults to None |
None
|
learning_rate |
float
|
The learning rate of the model. Defaults to 1e-3. |
0.001
|
loss |
Optional[str]
|
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 |
None
|
metrics |
Optional[List[str]]
|
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in |
None
|
metrics_prob_input |
Optional[bool]
|
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. |
None
|
metrics_params |
Optional[List]
|
The parameters to be passed to the metrics function. |
None
|
target_range |
Optional[List]
|
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 |
None
|
seed |
int
|
The seed for reproducibility. Defaults to 42 |
42
|
Source code in src/pytorch_tabular/config/config.py
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 |
|
Model Classes¶
Bases: BaseModel
Source code in src/pytorch_tabular/models/autoint/autoint.py
Bases: BaseModel
Source code in src/pytorch_tabular/models/category_embedding/category_embedding_model.py
Bases: BaseModel
Source code in src/pytorch_tabular/models/danet/danet.py
Bases: BaseModel
Source code in src/pytorch_tabular/models/ft_transformer/ft_transformer.py
Bases: BaseModel
Source code in src/pytorch_tabular/models/gandalf/gandalf.py
Bases: BaseModel
Source code in src/pytorch_tabular/models/gate/gate_model.py
Bases: BaseModel
Source code in src/pytorch_tabular/models/mixture_density/mdn.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
|
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
Bases: BaseModel
Source code in src/pytorch_tabular/models/tabnet/tabnet_model.py
Bases: BaseModel
Source code in src/pytorch_tabular/models/tab_transformer/tab_transformer.py
Base Model Class¶
Bases: LightningModule
Source code in src/pytorch_tabular/models/base_model.py
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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 |
|
__init__(config, custom_loss=None, custom_metrics=None, custom_metrics_prob_inputs=None, custom_optimizer=None, custom_optimizer_params={}, **kwargs)
¶
Base Model for PyTorch Tabular.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
DictConfig
|
The configuration for the model. |
required |
custom_loss |
Optional[Module]
|
A custom loss function. Defaults to None. |
None
|
custom_metrics |
Optional[List[Callable]]
|
A list of custom metrics. Defaults to None. |
None
|
custom_metrics_prob_inputs |
Optional[List[bool]]
|
A list of boolean values indicating whether the metric requires probability inputs. Defaults to None. |
None
|
custom_optimizer |
Optional[Optimizer]
|
A custom optimizer as callable or string to be imported. Defaults to None. |
None
|
custom_optimizer_params |
Dict
|
A dictionary of custom optimizer parameters. Defaults to {}. |
{}
|
kwargs |
Dict
|
Additional keyword arguments. |
{}
|
Source code in src/pytorch_tabular/models/base_model.py
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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
|
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_hat |
Tensor
|
The output of the model |
required |
Returns:
Type | Description |
---|---|
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
output |
Dict
|
The output dictionary from the model |
required |
y |
Tensor
|
The target tensor |
required |
tag |
str
|
The tag to use for logging |
required |
Returns:
Type | Description |
---|---|
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y |
Tensor
|
The target tensor |
required |
y_hat |
Tensor
|
The predicted tensor |
required |
tag |
str
|
The tag to use for logging |
required |
Returns:
Type | Description |
---|---|
List[Tensor]
|
List[torch.Tensor]: The list of metric values |
Source code in src/pytorch_tabular/models/base_model.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
|
compute_head(backbone_features)
¶
Computes the head of the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
backbone_features |
Tensor
|
The backbone features |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
The output of the model |