Professional Documents
Culture Documents
Machine Learning Programming Exercise 3: 1 Logistic Regression One-vs-All
Machine Learning Programming Exercise 3: 1 Logistic Regression One-vs-All
i.
[10 points] Randomly choose 100 of the pictures and display using the code displayData.m
that we give you. Then you should see an image like:
ii.
[40 points] Write a one-vs-all function that calculates thetas for all labels and returns them
as a matrix such that each row represents a theta vector. For this, use fmincg function that
is given to you and apply it when y is equal to different labels (e.g., c in the code below,
where c is a label index) using regularized logistic regression cost function.
For fmincg you can use the code below:
You can use your logistic regression cost function of Programmins Assignment 2 but make
sure that your code is vectorized.
iii.
iv.
[30 points] Predict the labels of the training set using the thetas you get from one-vs-all
function. Then, by comparing your predicted labels and the real labels, calculate the
training set accuracy.
[20 points] Using test_batch data, calculate the test set accuracy.