-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpredict.R
executable file
·45 lines (35 loc) · 1.13 KB
/
predict.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
#!/usr/bin/env Rscript
#
# Shyam Saladi ([email protected])
# Bil Clemons Laboratory (clemonslab.caltech.edu)
#
# input: svmlight model dat file, .RData file, name of transformation, input stats file
# output: predictions
#
library(tidyverse)
library(magrittr)
# install("myutils)
library(myutils)
main <- function(args) {
if (is.na(args[4])) {
cat("Need to supply a the following arguments:
1 - SVMlight model .dat file
2 - .RData file
3 - name of transformation variable (see preProcessing, R caret), e.g. *xtrans
4 - input .allstats.csv file\n", file = stderr())
quit()
}
# load the workspace that has the transformation data (for preprocessing)
load(args[2])
# read in csvfile with the calculated features
test_data <- read.csv(file = args[4], header = TRUE, as.is = TRUE)
xtrans <- get(args[3])
weights <- read_svmlight_model(args[1], names(xtrans$mean))
scores <- prediction_fn(test_data, xtrans, weights)
options(digits = 9)
cat(scores, sep = "\n")
}
if (!interactive()) {
args <- commandArgs(TRUE)
main(args)
}