Training a neural network for binary classification
In this recipe, let’s train our first neural network for a binary classification task on the breast cancer dataset. We will also learn more about the impact of the learning rate and the optimizer on the optimization, as well as how to evaluate the model against the test set.
Getting ready
As we will see in this recipe, training a neural network for binary classification is not so different from training a neural network for regression. Primarily, two changes have to be made:
- The output layer’s activation function
- The loss function
In the previous recipe for a regression task, the output layer had no activation function. Indeed, for a regression, one can expect the prediction to take any value.
For a binary classification, we expect the output to be a probability, so a value between 0 and 1, just like the logistic regression. This is why when doing a binary classification, the output layer...