Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

R project help # KNN Project # Since KNN is such a simple algorithm, we will just use this Project as a # simple exercise

R project help

# 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

code here

# 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.

# 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

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

Data Analytics Systems Engineering Cybersecurity Project Management

Authors: Christopher Greco

1st Edition

168392648X, 978-1683926481

More Books

Students also viewed these Databases questions

Question

Define the term Working Capital Gap.

Answered: 1 week ago