Model for training tabular/structured data

Simple model for tabular data

class TabularModel[source][test]

TabularModel(emb_szs:ListSizes, n_cont:int, out_sz:int, layers:Collection[int], ps:Collection[float]=None, emb_drop:float=0.0, y_range:OptRange=None, use_bn:bool=True, bn_final:bool=False) :: PrePostInitMeta :: Module

No tests found for TabularModel. To contribute a test please refer to this guide and this discussion.

Basic model for tabular data.

emb_szs match each categorical variable size with an embedding size, n_cont is the number of continuous variables. The model consists of Embedding layers for the categorical variables, followed by a Dropout of emb_drop, and a BatchNorm for the continuous variables. The results are concatenated and followed by blocks of BatchNorm, Dropout, Linear and ReLU (the first block skips BatchNorm and Dropout, the last block skips the ReLU).

The sizes of the blocks are given in layers and the probabilities of the Dropout in ps. The last size is out_sz, and we add a last activation that is a sigmoid rescaled to cover y_range (if it's not None). Lastly, if use_bn is set to False, all BatchNorm layers are skipped except the one applied to the continuous variables.

Generally it's easiest to just create a learner with tabular_learner, which will automatically create a TabularModel for you.