Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB Pages 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 3

MATLAB

Pages

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 3 outputs [predicted_labels, nn_index, 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.

Annotations

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

Semantics In Databases Second International Workshop Dagstuhl Castle Germany January 2001 Revised Papers Lncs 2582

Authors: Leopoldo Bertossi ,Gyula O.H. Katona ,Klaus-Dieter Schewe ,Bernhard Thalheim

2003rd Edition

3540009574, 978-3540009573

More Books

Students also viewed these Databases questions

Question

What are conventional, vertical, and horizontal marketing systems?

Answered: 1 week ago