Question: 3 Big Data Analytics - Homework 3 Question 3. [40 points] We use KNN 7 to predict the class (LEAVE/ STAY) using the dataset CHURN.

 3 Big Data Analytics - Homework 3 Question 3. [40 points]

3 Big Data Analytics - Homework 3 Question 3. [40 points] We use KNN 7 to predict the class (LEAVE/ STAY) using the dataset CHURN. (a) Warmup: Copy the IRIS code and implement the KNN algorithm. What does the last line mean? library(caret) data("iris") data = iris set.seed (1) ind = sample(seq(1,150,1), 100, replace=FALSE) xtraining = data[ind, 1:41 ytraining = data[ind, 5] xtesting = data[-ind, 1:4] ytesting = data[-ind, 5] knn = knn3(xtraining, ytraining, k=3) knn y = predict(knn, newdata=xtesting, type=c('class')) sum(as. numeric(y == ytesting) (b) Why it is not good to choose an even number as k? (c) Load the dataset churn.arff' into R. (d) Set the seed number equal to 1, and split the data equally into training and testing. The training and testing data for features contain columns 2 to 7 only. (e) Use knn3 function in caret to implement knn algorithm using k=3. Report the accuracy rate. Use knn3 function in caret to implement knn algorithm using k=5. Report the accuracy rate. (9) Use knn3 function in caret to implement knn algorithm using k=11. Report the accuracy rate. (h) How many neighbors k will you choose? You can get the 'churn.arff @https://ws28.cn/f/4yi36ulxs4o 3 Big Data Analytics - Homework 3 Question 3. [40 points] We use KNN 7 to predict the class (LEAVE/ STAY) using the dataset CHURN. (a) Warmup: Copy the IRIS code and implement the KNN algorithm. What does the last line mean? library(caret) data("iris") data = iris set.seed (1) ind = sample(seq(1,150,1), 100, replace=FALSE) xtraining = data[ind, 1:41 ytraining = data[ind, 5] xtesting = data[-ind, 1:4] ytesting = data[-ind, 5] knn = knn3(xtraining, ytraining, k=3) knn y = predict(knn, newdata=xtesting, type=c('class')) sum(as. numeric(y == ytesting) (b) Why it is not good to choose an even number as k? (c) Load the dataset churn.arff' into R. (d) Set the seed number equal to 1, and split the data equally into training and testing. The training and testing data for features contain columns 2 to 7 only. (e) Use knn3 function in caret to implement knn algorithm using k=3. Report the accuracy rate. Use knn3 function in caret to implement knn algorithm using k=5. Report the accuracy rate. (9) Use knn3 function in caret to implement knn algorithm using k=11. Report the accuracy rate. (h) How many neighbors k will you choose? You can get the 'churn.arff @https://ws28.cn/f/4yi36ulxs4o

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!