-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_models.py
41 lines (30 loc) · 1.19 KB
/
generate_models.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
from datetime import datetime
import os
import random
from shutil import copyfile
import constants
import plots
import utils
from Parameters import Parameters
from markov import mkv
def create(file_name, file_in_sep, random_seed, params):
"""Generate tps, classes and patterns from sequences in file_in"""
# set random
random.seed(random_seed)
# Create target dir if don't exist
dir_out = "data/models/" + file_name + "_" + str(random_seed) + "_" +\
str(params.mkv_thr) + "_" + str(params.fc_thr) + "_" + str(params.fc_n_ctx) + "_" + str(params.fc_seg_ord) + "/"
if not os.path.exists(dir_out):
os.mkdir(dir_out)
else:
print("Directory ", dir_out, "already exists")
# calculate model and form classes
ti = datetime.now()
sequences = utils.read_from_file("data/" + file_name + ".txt", separator=file_in_sep)
tp, tps, cls, ptns = mkv.compute(sequences, params, dir_name=dir_out + "model/")
print("Model of " + file_name + " computed... time: ", (datetime.now() - ti).total_seconds(), "s.")
# plots.plot_tps(dir_out, tps)
return dir_out
if __name__ == "__main__":
pars = Parameters()
create("bicinia", " ", 8, pars)