Skip to content

Instantly share code, notes, and snippets.

@Zoldin
Last active July 21, 2017 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zoldin/bfc2d4ee449098a9ff64b99c3326e61d to your computer and use it in GitHub Desktop.
Save Zoldin/bfc2d4ee449098a9ff64b99c3326e61d to your computer and use it in GitHub Desktop.
evaluate.R
#!/usr/bin/Rscript
library(Matrix)
library(glmnet)
args = commandArgs(trailingOnly=TRUE)
if (!length(args)==3) {
stop("Three arguments must be supplied ( file name where model is stored (RDataname), test file (.txt, matrix) and file name for AUC output).n", call.=FALSE)
}
#read test data set and model
load(args[1])
testMM = readMM(args[2])
testMM_reg <- as.matrix(testMM)
#predict test data
preds = predict(glmnet_classifier, testMM_reg[,2:500] , type = 'response')[, 1]
glmnet:::auc(testMM_reg[,1], preds)
#write AUC into txt file
write.table(file=args[3],paste('AUC for the test file is : ',glmnet:::auc(testMM_reg[,1], preds)),row.names = FALSE,col.names = FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment