Question: Implement a multi-layer perceptron (MLP) classifier and the backpropagation algorithm to train it on the Maternal Health Risk Data dataset. This dataset was collected from
Implement a multi-layer perceptron (MLP) classifier and the backpropagation algorithm to train it on the "Maternal Health Risk Data" dataset. This dataset was collected from medical institutions to identify health conditions that pose the greatest risks during pregnancy.
a. (1 point) Implement the forward pass of a two-layer MLP (i.e., with a single hidden layer) classifier that uses sigmoid activation for both the hidden layer and output layer. The output layer has a single node. - Randomly initialize weights and biases in the range of [-1, 1).
b. (2 points) Implement the backpropagation algorithm using squared error loss.
c. (1.5 points) Implement a training function. Train your model on the training set with default hyperparameters provided in the skeleton code. Use the entire training set as a batch, i.e., computing the gradient on the entire dataset in each iteration. Plot the error versus the number of epochs and report classification accuracies on subsets.
Note: When we have a very large dataset, it would be computationally expensive to compute the gradient on the entire dataset in each iteration, and people often compute a stochastic gradient using a small subset (called a batch) in each iteration. You are welcome to try it, but there is no extra credit for this exploration.
d. (1.5 points) Experiment with hyperparameters such as number of iterations, learning rate, and hidden layer size to evaluate how accuracy is affected. Use validation data to identify the best set of hyperparameters. If you are not confident about your own implementation, you may use sklearn.neural_network.MLPClassifier instead for this question. Record the changes made, the reasoning behind the changes, and the results in your report.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
