Icon

02_​Adult_​Data_​Classification_​Solution

Adult data income classification with ANN

Exercise of the L4-DL Deep Learning Specialization course.

The dataset contains some demographic information from 32k adults collected by the US Census. The goal of this exercise is to predict whether a person's income is above $50k. We do so by building an ANN model for binary classification.

URL: L4-DL course slides https://www.knime.com/form/material-download-registration

Step 2. Keras Architecture

  1. Layer 1 (input layer): Keras Input Layer node with Shape 13

  2. Layer 2 (hidden layer): Keras Dense Layer node with Shape 6, ReLu Activation function

  3. Layer 3 (hidden layer): Keras Dense Layer node with Shape 6, ReLu Activation function

  4. Layer 4 (output layer): Keras Dense Layer node with Shape 1, Sigmoid Activation function



Step 1. Data Preparation

There are 13 features available, as well as the binary target Income, in this dataset. While some of them are numerical, the others are categorical. These categorical features need to be converted to numbers. Since the education level is ordered, we use a table of education levels with the corresponding numerical encoding. Other categorical features are converted to numbers by the Category to number node. The dataset is partitioned into the training set 70% and the rest 30%. The second partition is further separated into the validation and testing sets (30% and 70%, respectively). All the features are then normalized [0, 1] before the analysis by the ANN. These preprocessing steps have been implemented by two metanodes.



Session 1 - Classical Neural Networks

Exercise 02 Adult data income classification with ANN

Learning objective: In this exercise, you'll learn how to train a multilayer perceptron with 13 input neurons, two hidden layer with 6 neurons, and an output layer with 1 neurons, using Backpropagation, to classify the Iris dataset.


Workflow description: The dataset contains some demographic information from 32k adults collected by the US Census. The goal of this exercise is to predict whether a person's income is above $50k. We do so by building an ANN model for binary classification.


You'll find the instructions to the exercises in the yellow annotations.

Step 3. Train the network model with the Keras Network Lerner node

  1. The training and validation sets should be supplied

  2. Input: Conversion is From Number (double), all 13 features are included as the input (i.e., everything except income)

  3. Target Data: Conversion is From Number (double), and income is selected. Loss function is Binary cross entropy

  4. Options: Batch size 100 for both training and validation. 20 Epochs. Adam Optimizer



Step 4. Apply the trained network to the testing set with the Keras Network Executor node

  1. Keep input columns in output table

  2. Inputs: Conversion is From Number (double), include all available features

  3. Outputs: click on add output, Conversion is To Number (double)



Step 5. Convert the network outcome to binary categories with the Expression node

If the predicted probability > 0.5, then the predicted category is >50K. Otherwise the predicted category is <=50K



Step 6. Assess the accuracy with the Scorer node

Compare the target column vs. the prediction from the network



Partition data into 70% training 30% rest Paritioning the rest to 30% validation 70% testing Normalize all features to [0,1]
Partitioning Normalization
Hidden layer 6 units ReLU
Keras Dense Layer
13 input features
Keras Input Layer
Output 1 unit Sigmoid
Keras Dense Layer
Hidden layer 6 units ReLU
Keras Dense Layer
Checkmodel performance
Scorer
Train networkBatch size: 100Epochs: 20Optimizer: adam
Keras Network Learner
Convert output
Expression
Read dictionarytable for educationcategories
Excel Reader
Prediction from the testing set
Keras Network Executor
Read adult.csv
CSV Reader
Convert nominalfeatures tonumerical
Nominal feature conversion

Nodes

Extensions

Links