-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathawsTrainModels.r
More file actions
executable file
·50 lines (26 loc) · 931 Bytes
/
Copy pathawsTrainModels.r
File metadata and controls
executable file
·50 lines (26 loc) · 931 Bytes
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
46
47
48
49
setwd("../machinelearning_R")
path<-paste(getwd(),"serverFunctions.r",sep="/")
invisible(source(path))
#recieve input facility name from command line
#Rscript awsTrainModels.r facilityName
args = commandArgs(trailingOnly=TRUE)
#default location
if(length(args)==0){
#dataPath <- "prepared-data/UCIdata.rds"
facilityName <- "Brocolândia"
}
facilityName <- args[1]
pathData <- paste("prepared-data/",facilityName,".rds",sep="")
tidyData <- readRDS(pathData)
#SCALE DATA
idZ <- tidyData$idZ
tidyData <- dplyr::select(tidyData,-idZ)
#NON PCA SCALING
preProc <- caret::preProcess(tidyData)
scaled <- predict(preProc, tidyData)
#now, we train the models with data already scaled
trainedModels <- trainModels(scaled)
#save scaling object with models!
trainedModels<- c(trainedModels,"preProc"=list(preProc))
pathModels <- paste("trainedModels/",facilityName,".rds",sep="")
saveRDS(trainedModels,pathModels)