6. Regularization and Hyperparameter Tuning
Activity 6.01: Predicting Income with L1 and L2 Regularizers
Solution:
- Open a new Jupyter notebook.
- Import the pandas library and use
pd
as the alias:import pandas as pd
- Create a list called
usecols
containing the column namesAAGE
,ADTIND
,ADTOCC
,SEOTR
,WKSWORK
, andPTOTVAL
:usecols = ['AAGE','ADTIND','ADTOCC','SEOTR','WKSWORK', 'PTOTVAL']
- Create a variable called
train_url
that contains the URL to the training set:train_url = 'https://raw.githubusercontent.com/PacktWorkshops'\ '/The-TensorFlow-Workshop/master/Chapter06'\ '/dataset/census-income-train.csv'
- Load the training dataset into a DataFrame,
train_data
, using theread_csv()
method. Provide the URL to the CSV file and theusecols...