This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
forked from cuamc-dop-ids/hptbi-hackathon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtraining.py
46 lines (30 loc) · 1.6 KB
/
training.py
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
################################################################################
# HACKATHON PARTICIPANTS -- DO NOT EDIT THIS FILE #
################################################################################
import sys
import time
import pickle
response = str(sys.argv[1])
exec(open("prepare_" + response + "_data.py").read())
exec(open(response + "_model.py").read())
################################################################################
# build the training data set and record the time required to do so.
tic = time.time()
training_data = eval("prepare_" + response + "_data(training = True)")
toc = time.time()
evaluation_file = open("./output/evaluation.txt", "a")
out = "seconds elapsed to prepare " + response + " training data | " + str(toc - tic) + "\n"
evaluation_file.write(out)
################################################################################
# Train the model and record the time required to do so.
tic = time.time()
trained_model = eval(response + "_model(training_data)")
toc = time.time()
#saveRDS(trained_model, file = paste0("./output/trained_", response, "_model.rds"))
pickle.dump(trained_model, open("./output/trained_" + response + "_model.pickle", "wb"))
out = "seconds elapsed to train the " + response + " model | " + str(toc - tic) + "\n"
evaluation_file.write(out)
evaluation_file.close()
###############################################################################
# End of File #
################################################################################