Downloads · 30 days
38
3% of all-time downloads
keras-io/structured-data-classification-grn-vsn
structured-data-classification-grn-vsn is a tabular classification model from keras-io. Use it for the tabular classification task on the model card, and read the license before you ship it in a product. It is set up for tf-keras.
This model is built using two important architectural components proposed by Bryan Lim et al. in Temporal Fusion Transformers (TFT) for Interpretable Multi-horizon Time Series Forecasting called GRN and VSN which are…
Downloads · 30 days
38
3% of all-time downloads
All-time downloads
1.4K
Public
Repo size
38.9 MB
Likes
10
Public
Click a slice to open those files.
.v214.4 MB · 54%
From the Hugging Face model README
This model is built using two important architectural components proposed by Bryan Lim et al. in Temporal Fusion Transformers (TFT) for Interpretable Multi-horizon Time Series Forecasting called GRN and VSN which are very useful for structured data learning tasks.
Gated Residual Networks(GRN): consists of skip connections and gating layers that facilitate information flow efficiently. They have the flexibility to apply non-linear processing only where needed. GRNs make use of Gated Linear Units (or GLUs) to suppress the input that are not relevant for a given task.
The GRN works as follows:
Variable Selection Networks(VSN): help in carefully selecting the most important features from the input and getting rid of any unnecessary noisy inputs which could harm the model's performance. The VSN works as follows:
Note: This model is not based on the whole TFT model described in the mentioned paper on top but only uses its GRN and VSN components demonstrating that GRN and VSNs can be very useful on their own also for structured data learning tasks.
This model can be used for binary classification task to determine whether a person makes over $500K a year or not.
This model was trained using the United States Census Income Dataset provided by the UCI Machine Learning Repository. The dataset consists of weighted census data containing demographic and employment related variables extracted from 1994 and 1995 Current Population Surveys conducted by the US Census Bureau. The dataset comprises of ~299K samples with 41 input variables and 1 target variable called income_level The variable instance_weight is not used as an input for the model so finally the model uses 40 input features containing 7 numerical features and 33 categorical features:
| Numerical Features | Categorical Features |
|---|---|
| age | class of worker |
| wage per hour | industry code |
| capital gains | occupation code |
| capital losses | adjusted gross income |
| dividends from stocks | education |
| num persons worked for employer | veterans benefits |
| weeks worked in year | enrolled in edu inst last wk |
| marital status | |
| major industry code | |
| major occupation code | |
| mace | |
| hispanic Origin | |
| sex | |
| member of a labor union | |
| reason for unemployment | |
| full or part time employment stat | |
| federal income tax liability | |
| tax filer status | |
| region of previous residence | |
| state of previous residence | |
| detailed household and family stat | |
| detailed household summary in household | |
| migration code-change in msa | |
| migration code-change in reg | |
| migration code-move within reg | |
| live in this house 1 year ago | |
| migration prev res in sunbelt | |
| family members under 18 | |
| total person earnings | |
| country of birth father | |
| country of birth mother | |
| country of birth self | |
| citizenship | |
| total person income | |
| own business or self employed | |
| taxable income amount | |
| fill inc questionnaire for veteran's admin |
The dataset already comes in two parts meant for training and testing. The training dataset has 199523 samples whereas the test dataset has 99762 samples.
Prepare Data: Load the training and test datasets and convert the target column income_level from string to integer. The training dataset is further split into train and validation sets. Finally, the training and validation datasets are then converted into a tf.data.Dataset meant to be used for model training and evaluation.
Define logic for Encoding input features: We encode the categorical and numerical features as follows:
Categorical Features: are encoded using Embedding layer provided by Keras. The output dimension of the embedding is equal to encoding_size
Numerical Features: are projected into a encoding_size dimensional vector by applying a linear transformation using Dense layer provided by Keras
Therefore, all the encoded features will have the same dimensionality equal to the value of encoding_size.
Create Model:
Compile, Train and Evaluate Model:
The following hyperparameters were used during training:
| Hyperparameters | Value |
|---|---|
| name | Adam |
| learning_rate | 0.0010000000474974513 |
| decay | 0.0 |
| beta_1 | 0.8999999761581421 |
| beta_2 | 0.9990000128746033 |
| epsilon | 1e-07 |
| amsgrad | False |
| training_precision | float32 |
