-
Notifications
You must be signed in to change notification settings - Fork 0
/
visualization.py
82 lines (74 loc) · 2.88 KB
/
visualization.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python3
import argparse
import os
from matplotlib import pyplot as plt
import data_generator
plt.style.use('ggplot')
import model
def parse_arguments():
parser = argparse.ArgumentParser(description='Plot synthetic time series with extrema')
parser.add_argument('--quantity',
'-q',
help='Quantity of random subseries to plot',
type=int,
nargs='?',
default=4)
parser.add_argument('--mode',
'-m',
help='Mode how plots will be drawn. "together" on one figure; "separate" on separate',
type=str,
nargs='?',
default='together')
parser.add_argument('-N',
help='N, length of one time series',
type=int,
nargs='?',
default=1024)
parser.add_argument('-M',
help='M, multiplier. N*M = length of the whole time series',
type=int,
nargs='?',
default=1000)
parser.add_argument('-T',
help='T, multiplier for extremum constraint. The bigger T the less extrema will be found',
type=float,
nargs='?',
default=5.2)
parser.add_argument('-k',
help='k, extremum constraint. k + 1 = minimum points between two extrema',
type=int,
nargs='?',
default=3)
parser.add_argument('--seed',
'-s',
help='seed to generate time series',
type=int)
parser.add_argument('--prediction',
help='add predictions to plots',
dest='prediction',
action='store_true')
parser.add_argument('--no-prediction',
help='do not add predictions to plots',
dest='prediction',
action='store_false')
parser.set_defaults(prediction=False)
return parser.parse_args()
if __name__ == '__main__':
args = parse_arguments()
quantity = args.quantity
mode = args.mode
N = args.N
M = args.M
T = args.T
k = args.k
seed_generate = args.seed
make_prediction = args.prediction
data = data_generator.SyntheticSeries(N, M, k)
data.generate(seed=seed_generate)
data.calculate_extrema(T)
if make_prediction:
extrem_model = model.Model(N)
extrem_model.load(os.path.dirname(__file__) + '/model_weights/extremNet.pth')
else:
extrem_model = None
data.plot_random_subseries(quantity=quantity, mode=mode, prediction_model=extrem_model)