Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions

Question

Define mission?

Answered: 1 week ago

Question

Question What are the requirements for a SIMPLE 401(k) plan?

Answered: 1 week ago