-
Notifications
You must be signed in to change notification settings - Fork 0
/
createMLFunc.R
31 lines (29 loc) · 905 Bytes
/
createMLFunc.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
require(caret)
require(doMC)
createMLFunction<-function(input_table_list, ncores=2){
set.seed(5)
registerDoMC(ncores)
grid<-expand.grid(C=0.001)
trC<-trainControl(method = "cv",
number = 5,
repeats = 5,
#timingSamps=1,
verboseIter = FALSE,
allowParallel = TRUE,
classProbs=FALSE)
model_list<-list()
for (i in 1:nrow(input_table_list$PSI)){
print(i)
resp<-input_table_list$PSI[i,]
model<-train(x = t(input_table_list$FPKM),
y = as.numeric(resp),
method = "svmRadialCost",
preProcess = c("center", "scale"),
tuneGrid=grid,
trControl = trC,
metric="RMSE")
model_list[[i]]<-varImp(model, scale = FALSE, drop = FALSE)
gc()
}
return(model_list)
}