Course Hero Logo

Homework 2 .docx.pdf - Question 3.1 Using the same data set...

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 3 out of 7 pages.

Question 3.1Using the same data set (credit_card_data.txtorcredit_card_data-headers.txt) as in Question 2.2, use theksvmorkknnfunction tofind a good classifier:(a)using cross-validation (do this for the k-nearest-neighbors model; SVM is optional); and(b)splitting the data into training, validation, and test data sets (pick either KNN or SVM; the otheris optional).a)
b)I loaded the data and set the seed to allow replication of random variables> credit_data <- read.table("credit_card_data.txt", header=F, stringsAsFactors = F)> set.seed(1)I generated a random sample of 70% of data> random_row<- sample(1:nrow(credit_data),as.integer(0.7*nrow(credit_data))) > trainData =credit_data[random_row,]The remaining data (30%) was used for test and validation> remainingData = credit_data[-random_row,]

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 7 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Summer
Professor
N/A
Tags
Predictor

Newly uploaded documents

Show More

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture