Question: The algorithm for KNN classification model is given below: Algorithm: KNearestNeighbors , Input: , Training data x , , Training , , data labels ,
The algorithm for KNN classification model is given below:
Algorithm: KNearestNeighbors
Input: Training data
Training
data labels
Sample
to classify
Output: Decision yp about sample
for ilarr to do
Compute distance between training sample and
unlabeled sample ie
end for
Compute set I containing the indices for the smallest distances Compute the decision class pby measuring the majority
label Y from I return p
Task
Write a program to implement KNN classifier on heartstatlogclevelandhungarydata and classify given dataset.
Load dataset
Perform required preprocessing on data
Split dataset into test and train sets
Perform algorithm to make predictions for and as well.
Compute accuracy and confusion matrix
Find accuracy for each value of and display and for different splits as :::
Find the best which gives highest value of accuracy and worst which gives worst accuracy
Also compute confusion matrix for both best and worst value of
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
