- Hands-On Neural Networks with Keras
- Niloy Purkait
- 233字
- 2025-04-04 14:37:33
Exploring the data
This dataset is a much smaller dataset in comparison to the ones we've dealt with so far. We can only see 404 training observations and 102 test observations:
print(type(x_train),'training data:',x_train.shape,'test data:',x_test.shape)
<class 'numpy.ndarray'>training data:(403, 13) test data: (102, 13)
We will also generate a dictionary containing the description of our features so that we can understand what each of them actually encodes:
column_names=['CRIM','ZN','INDUS','CHAS','NOX','RM','AGE','DIS','RAD','TAX','PTRATIO','B','LST
AT']
key= ['Per capita crime rate.',
'The proportion of residential land zoned for lots over 25,000
square feet.',
'The proportion of non-retail business acres per town.',
'Charles River dummy variable (=1 if tract bounds river; 0
otherwise).',
'Nitric oxides concentration (parts per 10 million).',
'The average number of rooms per dwelling.',
'The porportion of owner-occupied units built before 1940.',
'Weighted distances to five Boston employment centers.',
'Index of accessibility to radial highways.',
'Full-value property tax rate per $10,000.',
'Pupil-Teacher ratio by town.',
'1000*(Bk-0.63)**2 where Bk is the proportion of Black people by
town.',
'Percentage lower status of the population.'}
Now let's create a pandas DataFrame and have a look at the first five observations in our training set. We will simply pass out the training data, along with the previously defined column names, as arguments to the pandas DataFrame constructor. Then, we will use the .head() parameter on our newly forged .DataFrame object to get a nice display, as follows:
import pandas as pd
df= pd.DataFrame(x_train, columns=column_names)
df.head()