3) The code below shows the K-Nearest Neighbour (ANN) algorithm on 3 species of Iris (Iris setosa, Iris virginica, Iris

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

3) The code below shows the K-Nearest Neighbour (ANN) algorithm on 3 species of Iris (Iris setosa, Iris virginica, Iris

Post by answerhappygod »

3 The Code Below Shows The K Nearest Neighbour Ann Algorithm On 3 Species Of Iris Iris Setosa Iris Virginica Iris 1
3 The Code Below Shows The K Nearest Neighbour Ann Algorithm On 3 Species Of Iris Iris Setosa Iris Virginica Iris 1 (27.14 KiB) Viewed 20 times
3) The code below shows the K-Nearest Neighbour (ANN) algorithm on 3 species of Iris (Iris setosa, Iris virginica, Iris versicolor). Based on the code provide, please explains algorithm procedure to obtain the best approximation of k the output of confusion matrix (5 Marks) (5 Marks) iii the best numbers of k and how we can determine the threshold values of k (maximum number of accuracy) (10 Marks) "you may run the code to answer (ii) & (iii). For (i): required modification of the code #Installing Packages install packages("e1071") install packages("caTools") install packages("class") Loading package Ibrary(1071) Ibrary(caTools) ibrary/class) Loading data data(iris) head(iris) #Splitting data into train #and test data split-sample.splitris, SplitRatio - 0.7) train de subset(iris, split "TRUE") test_cl<-subsetris, split == "FALSE") Feature Scaling train_scale-scale(train_c. 1:4) test scale-scale(test 1:4 #Fitting KNN Model to training dataset classifier knn knn(train train scale, classifier ken test test scale, cl-train_clsSpecies, cm k=1) Confusin Matrix cm-table(test_clsSpecies, classifier_kn) Model Evaluation Choosing K Calculate out of Sample error misClassError<- mean(classifier_knn t test_clsSpecies) printipastel'Accuracy, 1-misClassError) WK=2 classifier kan knntrain train scale. test test scale. dl-train c$Species, k=2) misClassError mean(classifier knn t test_clsSpecies) printipastel'Accuracy, 1-misClassError)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply