Binary classification problems
In this exercise, you will again make use of credit card data. The target variable, default, indicates whether a credit card holder defaults on his or her payment in the following period. Since there are only two options--default or not--this is a binary classification problem. While the dataset has many features, you will focus on just three: the size of the three latest credit card bills. Finally, you will compute predictions from your untrained network, outputs, and compare those the target variable, default.
The tensor of features has been loaded and is available as bill_amounts. Additionally, the constant(), float32, and keras.layers.Dense() operations are available.
This exercise is part of the course
Introduction to TensorFlow in Python
Exercise instructions
- Define
inputsas a 32-bit floating point constant tensor usingbill_amounts. - Set
dense1to be a dense layer with 3 output nodes and areluactivation function. - Set
dense2to be a dense layer with 2 output nodes and areluactivation function. - Set the output layer to be a dense layer with a single output node and a
sigmoidactivation function.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Construct input layer from features
inputs = ____
# Define first dense layer
dense1 = keras.layers.Dense(____, activation='____')(inputs)
# Define second dense layer
dense2 = ____
# Define output layer
outputs = ____
# Print error for first five examples
error = default[:5] - outputs.numpy()[:5]
print(error)