Chapter 5: Artificial Neural Networks: Predict Annual Income
Activity 14: Training a Multilayer Perceptron for our Census Income Dataset
- Using the preprocessed Census Income Dataset, separate the features from the target, creating the variables
X
andY
:X = data.drop("target", axis=1) Y = data["target"]
As explained previously, there are several ways to achieve the separation of
X
andY
, and the main thing to consider is thatX
should contain the features for all instances, whileY
should contain the class label of all instances. - Divide the dataset into training, validation, and testing sets, using a split ratio of 10%:
from sklearn.model_selection import train_test_split X_new, X_test, Y_new, Y_test = train_test_split(X, Y, test_size=0.1, random_state=101) X_train, X_dev, Y_train, Y_dev = train_test_split(X_new, Y_new, test_size=0.1111, random_state=101)
The shape of the sets created should be as follows:
X_train = (26048, 9) X_dev = (3256, 9) X_test = ...