Mercurial > repos > deepakjadmin > r_caret_test1
comparison caret_future/tool3/Preold.R.ORIG @ 0:a4a2ad5a214e draft default tip
Uploaded
author | deepakjadmin |
---|---|
date | Thu, 05 Nov 2015 02:37:56 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a4a2ad5a214e |
---|---|
1 ########## | |
2 args <- commandArgs(TRUE) | |
3 nTrain <- read.csv(args[1],row.names= 1, header = T) # example nTrain.csv file of unknown activity | |
4 #save(nTrain,file = "nTrain.RData") | |
5 #load("nTrain.RData") | |
6 load(args[2]) # model generated from previous programn | |
7 newdata <- nTrain | |
8 modelFit <- Fit | |
9 ########### | |
10 # input csv file must contaion the exact same column as used in model building # | |
11 # Also do pre-proccessing by means of centering and scaling | |
12 | |
13 library(caret) | |
14 reqcol <- Fit$finalModel$xNames | |
15 newdata <- newdata[,reqcol] | |
16 newdata1 <- preProcess(newdata, method = c("center", "scale")) | |
17 newdata11 <- predict(newdata1,newdata) | |
18 ########### | |
19 library(stats) | |
20 testpredict <- predict(modelFit,newdata11) | |
21 #table(testpredict) | |
22 #save(testpredict, file = "predict.RData") | |
23 #load("predict.RData") | |
24 names <- as.data.frame(rownames(nTrain)) | |
25 colnames(names) <- "COMPOUND" | |
26 activity <- as.data.frame(testpredict) | |
27 colnames(activity) <- "ACTIVITY" | |
28 dw <- cbind(names,activity) | |
29 #write.table(dw,file=args[3]) | |
30 write.csv(dw,file=args[3],row.names=FALSE) | |
31 | |
32 | |
33 ~ |