Question: ONLY MATLAB ONLY ONLY MATLAB #MATLAB Write a function that will predict the unknown class label using the k-NN classifier algorithm. You can assume there

ONLY MATLAB ONLY ONLY MATLAB #MATLAB

ONLY MATLAB ONLY ONLY MATLAB #MATLAB Write a function that will predict

Write a function that will predict the unknown class label using the k-NN classifier algorithm. You can assume there will be two classes. Use the Euclidean distance measure. The function should accept as input: . the training set (the set including those instances with known labels, e.g., a 30x2 matrix for 15 sardines and 15 tuna fish, d=2), the label vector (the class labels of the training instances, e.g., a 30x1 vector), the instance with the unknown label (e.g., a 1x2 vector), the value of k, . . and give as the output: . the predicted class label of the instance. Write a script that will call this function: . . to predict the class labels of all the instances given in the validation set, to calculate TCC per given k value, to plot TCC vsk, to print (on the command window): the k value with the maximum TCC, and the corresponding the confusion matrix. . O Sweep over the values of k from 1 to 35 (Hint: k should be an odd value when you have two classes). Notes: You may decide your own way of writing your script/function. Correct outcome and efficiency should be your target. The training and validation sets for this project are given in the mat-file named DATA.mat. The third columns have the class labels. The data is arbitrary, i.e., the two dimensions are not the length and the width of sardines and tuna fish :) We can talk about both the training error and the validation error in classification. Accordingly, one can build two confusion matrices: one for the training set and the other for the validation set. Here, you are asked to build the latter: the one for the validation set only. We do not consider the instances in the validation set "neighbors to each-other as implied by the name of the algorithm. The training instances are the neighbors (of the validation instance) to look at, so to speak. . . Write a function that will predict the unknown class label using the k-NN classifier algorithm. You can assume there will be two classes. Use the Euclidean distance measure. The function should accept as input: . the training set (the set including those instances with known labels, e.g., a 30x2 matrix for 15 sardines and 15 tuna fish, d=2), the label vector (the class labels of the training instances, e.g., a 30x1 vector), the instance with the unknown label (e.g., a 1x2 vector), the value of k, . . and give as the output: . the predicted class label of the instance. Write a script that will call this function: . . to predict the class labels of all the instances given in the validation set, to calculate TCC per given k value, to plot TCC vsk, to print (on the command window): the k value with the maximum TCC, and the corresponding the confusion matrix. . O Sweep over the values of k from 1 to 35 (Hint: k should be an odd value when you have two classes). Notes: You may decide your own way of writing your script/function. Correct outcome and efficiency should be your target. The training and validation sets for this project are given in the mat-file named DATA.mat. The third columns have the class labels. The data is arbitrary, i.e., the two dimensions are not the length and the width of sardines and tuna fish :) We can talk about both the training error and the validation error in classification. Accordingly, one can build two confusion matrices: one for the training set and the other for the validation set. Here, you are asked to build the latter: the one for the validation set only. We do not consider the instances in the validation set "neighbors to each-other as implied by the name of the algorithm. The training instances are the neighbors (of the validation instance) to look at, so to speak

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!