Question: MATLAB Develop a machine learning algorithm using K-nearest neighbors. k-nearest neighbors algorithm Built a Function named Your mtuid_KNN.m which will take in 4 inputs (k,

MATLAB Develop a machine learning algorithm using K-nearest neighbors.

k-nearest neighbors algorithm Built a Function named Your mtuid_KNN.m which will take in 4 inputs (k, train_data, train_labels, test_data, test_labels) and gives 2 outputs [predicted_labels, accuracy] Example: function [predicted_labels,accuracy] = sspathru_KNN(k,train_data,train_labels,test_data,test_labels) Inputs: k: number of nearest neighbors (must be an odd number) train_data (NxD): training data; N is the number of samples and D is the dimensionality of each data point train_labels (Nx1): training labels test_data (MxD): testing data; M is the number of data points and D is the dimensionality of each data point. test_labels (Mx1): testing labels; test_labels are included to calculate accuracy; do not use test data for training. Output: predicted_labels: the predicted labels based on the k-NN algorithm. accuracy: % accuracy. Checks 1. Function should give an error message if k is an even number. 2. Function should give an error message if number of labels in training data and test data are not equal. 3. Function should work for any dimensional data. 4. Function should give an error for any dimensionality mismatch. 5. The function submitted by students would be checked for multiple datasets (2-D, 3-D, N-D). Make sure there is no hard coding involved. Deliverables: A single (.m) file should be submitted. mtuid_KNN.m Example: sspathru_KNN.m You can use the student_assessment_code.m to check if your KNN function is working as per requirement. Note: This assessment code does not check your function rigorously and has limited simple test cases. Your function will be tested for extremely complicated datasets while grading.

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!