-
Notifications
You must be signed in to change notification settings - Fork 0
/
Grid Search.R
46 lines (36 loc) · 921 Bytes
/
Grid Search.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#load e1071 library
library("e1071")
#Read in our dataset
films.df <- read.csv("films.csv")
#Attach this dataset
attach(films.df)
#Chop off first column for films' names (used for viewing purposes in Excel but not for R)
films.df <- films.df[,-1]
#Build model 1
model1 <- svm(Verdict ~ .,
data=films.df,
type="C-classification",
cost=0.1,
kernel="linear",
cross=5)
#Build model 2
model2 <- svm(Verdict ~ .,
data=films.df,
type="C-classification",
cost=1,
kernel="linear",
cross=5)
#Predict the models
pred1 <- fitted(model1)
pred2 <- fitted(model2)
#Construct the confusion matrices
cm1 <- table(Verdict, pred1)
cm2 <- table(Verdict, pred2)
print(cm1)
print(cm2)
model1 <- svm(HR ~ .,
data=films.df,
type="eps-regression",
cost=1,
kernel="linear",
epsilon=1)