Assignment 3
Assignment 3
Nazarahari
1. Guidelines:
• Submit the finalized codes (.mat file) as well as your report (.pdf file), including results and
engineering analysis, as a zip file on eClass.
• Include the assignment rubric on the first page of your report.
• You don’t need to include the finalized codes in your report. Only include the qualitative
answers or parameter investigation results.
• Your report must be produced with “Overleaf” using this template.
• Remark: Failing to comply with the above requirements will result in an assignment mark
reduction.
You are going to implement the backpropagation algorithm to train an MLP with a simple architecture
(input layer, one hidden layer, and output layer) to solve a two-class classification problem and then
compare your trained network with the one that can be obtained using MATLAB libraries.
The provided function named “Classification_ANN_Incomplete” contains all the codes and
functions (which you need to complete) to do this section of the assignment.
• Section 1: Creates a random dataset for a two-class classification problem. Variable “x” will
contain the data, and variable “t_org” will contain the true targets (true classes).
• Section 2: Contains the codes to create an MLP using MATLAB libraries, tests the trained
network using all input data, and plots the confusion matrix.
Page 1 of 6
MECE 694 M. Nazarahari
o “t_org contains” 1s for Class 1 and -1s for Class 2. Yet, to plot a confusion matrix
using the “plotconfusion” function in MATLAB, true targets and network outputs “y”
must have the following format:
Page 2 of 6
MECE 694 M. Nazarahari
• STEP 4: Use “fminunc” to find the set of network weights which minimizes objective function
value. Use “MyANNObjecFunction_Incomplete” to create the function handle for
“fminunc” (already done for you).
• STEP 5 and 6: roll the optimized network weights and predict the network targets using the
function “PredictMLPOutputs”. Finally, plot the confusion matrix (already done for you).
Notes:
• Your code only works for a two-class classification problem and a network with an input-
layer, one hidden-layer, and output-layer architecture.
• We used all the data to perform training (no validation). Thus, the percentages of validation
and test data in MATLAB MLP were set to 0.
• We used all the data to test our networks after training (Resubstitution Method).
Question 2
• (report) Compare the performance (accuracy from confusion plot) of your trained MLP with
MATLAB implementation of MLP by filling the following table:
• To make sure that your results are reliable, for each scenario (e.g., your MLP with 5 neurons
in hidden layer), execute the “Classification_ANN_Incomplete” 10 times and report the
average accuracy ± standard deviation (each execution generates a random dataset and
random initial weights for MLP).
• Briefly describe (qualitatively) the differences between “trainlm”, “trainbr”, and “trainscg” and
why one might achieve superior outcome compared to others (max 3 sentences for each).
• Discuss any performance difference observed between the best results of your MLP and
MATLAB MLP.
• Qualitatively describe (briefly - max 3 sentences) what changes are needed in the code if you
want to implement MLP with any desired number of hidden layers.
• Qualitatively describe (briefly - max 3 sentences) what changes are needed in the code if you
want to solve a multi-class classification problem.
Page 3 of 6
MECE 694 M. Nazarahari
Question 4
• (report) Compare the performance (accuracy obtained from confusion matrix) of your
implemented KSVM (Section 3) with MATLAB implementation of KSVM (Section 2) for
different kernel functions and for three random problems in the table below:
o To create a random problem, run Section 1 of “Classification_KSVM_Incomplete”.
Then, to get the results for each column (one problem), run Sections 2 and 3 with
proper settings and record accuracy from the confusion matrix. You are also
encouraged to add a few (!) figures of data and decision boundaries for your KSVM.
Page 4 of 6
MECE 694 M. Nazarahari
o To improve your KSVM performance, try various parameter values for each kernel
for a number of random problems before filling the above table, and then use the
selected parameter values to perform a comparison (report the selected parameters).
Random Problem 1 2 3
Your KSVM (Gaussian, Parameter = ?)
Your KSVM (Logistic, Parameter = ?)
Your KSVM (Hyperbolic Tangent, Parameter = ?)
MATLAB KSVM (Gaussian)
MATLAB KSVM (polynomial)
• Discuss the reasons for any performance difference between different Kernel functions for
your implementation of KSVM.
• For Gaussian Kernel, show the effect of Kernel parameters by varying the parameter in a
range (your choice) and reporting KSVM performance. Discuss your observations.
Page 5 of 6
MECE 694 M. Nazarahari
where the first two columns of each row contain the coordinates x and y of a cluster
center, and the third column shows the activation-value for that cluster center. When
the activation value is higher than 0.5, that cluster center is activated and data will be
assigned to that. On the other hand, when the activation value is less than 0.5, the
automatic clustering with GA will ignore that cluster center.
o All other steps of the GA in automatic and simple clustering approaches are the same.
Thus, you can use the same procedure for sorting solutions and crossover/mutation
operations.
• (report) Compare the performance of (1) within a class distance (WCD) and (2) DB Index for
four datasets and qualitatively/quantitively discuss the reason(s) for observed differences. As
the objective values are not comparable directly, you can present the number of correctly
clustered data points by comparing the GA result with true cluster labels in variable “t” (for
each case, you might execute the GA a few times and report only one which seems better to
you).
Page 6 of 6