Description
Question 1: Unsupervised Learning: K-Means
Implement K-Means clustering on the Iris dataset using different configurations. Adjust
the number of clusters and iterations to observe their effects on the clustering results.
Visualize the clustered data and explain your findings regarding hyperparameter
adjustments. A guide file named Q-kmeans.py has been provided to help you with the
implementation. It includes a base framework where you must fill in the missing parts
per the instructions. Please provide the plots, setups (n_clusters, max_iter, etc.), and
analysis in report.pdf.
Instructions:
1. Load the Iris Dataset:
○ Use scikit-learn’s load_iris() function to load the dataset.
2. Implement K-Means Clustering:
○ Utilize the K-Means algorithm from scikit-learn to cluster the data.
○ Adjust the number of clusters, n_clusters: 2, 3, 4, and the number of
iterations, max_iter: 5, 10, 20.
3. Visualize the Results:
○ Plot the clustered data using two selected features (petal length and
width).
○ Use different colors to represent different clusters.
○ Mark cluster centroids on the plot.
4. Analyze and Report:
○ Explain how changing the number of clusters and iterations affects the
clustering results.
○ Discuss any patterns or observations from your visualizations.
Question 2: Neural Network: Backpropagation
In this question, you will manually compute a simple neural network’s forward and
backward pass with one hidden neuron. Perform all the computations step by step,
showing your work clearly. Use at least 4 decimal places in your calculations (you need
a calculator for some steps to maintain accuracy.
1. Perform a forward pass through the network to compute the output.
2. Calculate the loss using the Mean Squared Error (MSE) loss function.
3. Compute the gradients of the loss with respect to the weights using
backpropagation
4. Update the weights using gradient descent.
5. Repeat the forward pass with the updated weights to see how the network’s output
and loss have changed. See how the weights updates have moved the network
closer to the desired output.
Network Architecture:
● Input Layer: 2 neurons (x1 and x2)
● Hidden Layer: 1 neuron
● Hidden Layer Activation: Sigmoid function
● Output Layer: 1 neuron
● Output Layer Activation: Identity function (no activation)
● Loss Function: Mean Squared Error (MSE)
Given:
● Input: [x1, x2] = [1, 0]
● Label: y = 1
● Weights: [w1, w2, w3] = [0.5, -0.5, 0.5]
● Learning Rate: lr = 0.1
Question 3: Multi-Layer Perceptron (MLP)
In this question, you will work with a Multi-Layer Perceptron (MLP) neural network to
classify handwritten digits from the MNIST dataset. You will be provided with the code
Q-mlp.ipynb, The file is in notebook format and can be run on Google Colab. The file is in
notebook format and can be run on Google Colab. Here is a link to an introduction to how
to use Google Colab for running IPYNB files.
Your task is to modify specific hyperparameters in section 3, to investigate how each
affects the MLP’s performance (each parameter and its explanation will be worth points).
The parameters needed to adjust, evaluated, and reported are as follows:
● Number of Hidden Layers
● Number of Hidden Units in each Layer
● Learning Rate
● Number of Training Iterations (Epochs)
You will explore how changing the network’s architecture by adding more hidden layers,
different numbers of hidden units, and changing hyperparameters affects its
performance. There is a range provided for each parameter in the notebook. Just test the
system over the given range and there is no need for further values. Explain your findings
by adjusting the parameter and include the results for each experiment with its specific
setups in the report.
Remember, the main goal of this question is to give you a high-level understanding of how
changing the network parameters affects the overall performance of the system. Please
provide the plots, setups (parameter, # layers, etc.), and analysis in report.pdf.


