Question: NEED HELP FOR CODDING IN (R) # KNN Project # Since KNN is such a simple algorithm, we will just use this Project as a

NEED HELP FOR CODDING IN (R)

# KNN Project

# Since KNN is such a simple algorithm, we will just use this "Project" as a # simple exercise to test your understanding of the implementation of KNN. # By now you should feel comfortable implementing a machine learning # algorithm in R, as long as you know what library to use for it.

# So for this project, just follow along with the bolded instructions. # Get the Iris Data Set

# We'll use the famous iris data set for this project. It's a small data set # with flower features that can be used to attempt to predict the species of # an iris flower.

# Use the ISLR libary to get the iris data set. Check the head of the iris # Data Frame.

code here

# Standardize Data # In this case, the iris data set has all its features in the same order of #magnitude, but its good practice (especially with KNN) to standardize # features in your data. Lets go ahead and do this even though its not # necessary for this data!

# Use scale() to standardize the feature columns of the iris dataset. # Set this standardized version of the data as a new variable.

code here

# Check that the scaling worked by checking the variance of one of the new # columns

code here

# Join the standardized data with the response/target/label column # (the column with the species names.

code here

#################### # Train and Test Splits

# Use the caTools library to split your standardized data into train and # test sets. Use a 70/30 split.

code here

# Build a KNN model. library(class)

# Use the knn function to predict Species of the test set. Use k=1

code here

# What was your misclassification rate? code here

# Choosing a K Value # Although our data is quite small for us to really get a feel for choosing # a good K value, let's practice.

# Create a plot of the error (misclassification) rate for k values ranging # from 1 to 10.

code here

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!