

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Question 2. The files credit_card_data.txt (without headers) and credit_card_data-headers.txt (with headers) contain a dataset with 654 data points, 6 continuous and 4 binary predictor variables. It has anonymized credit card applications with a binary response variable (last column) indicating if the application was positive or negative. The dataset is the “Credit Approval Data Set” from the UCI Machine Learning Repository (https://archive.ics.uci.edu/ml/datasets/Credit+Approval) without the categorical variables and without data points that have missing values.
model <- ksvm(data[,1:10],data[,11],type=”C- svc”,kernel=”vanilladot”,C=100,scaled=TRUE)
a <- colSums(model@xmatrix[[1]] * model@coef[[1]]) a
a0 <- –model@b a
pred <- predict(model,data[,1:10]) pred
actual classification sum(pred == data[,11]) / nrow(data) Hint: You might want to view the predictions your model makes; if C is too large or too small, they’ll almost all be the same (all zero or all one) and the predictive value of the model will be poor. Even finding the right order of magnitude for C might take a little trial-and-error. (^1) I know I said I wouldn’t give you exact R code to copy, because I want you to learn for yourself. In general, that’s definitely true – but in this case, because it’s your first R assignment and because the ksvm function leaves you in the middle of a mathematical calculation that we haven’t gotten into in this course, I’m giving you the code.
Note: If you get the error “Error in vanilladot(length = 4, lambda = 0.5) : unused arguments (length = 4, lambda = 0.5)”, it means you need to convert data into matrix format: model <- ksvm(as.matrix(data[,1:10]),as.factor(data[,11]),type=”C- svc”,kernel=”vanilladot”,C=100,scaled=TRUE)