-
Notifications
You must be signed in to change notification settings - Fork 3
/
main_explo.py
71 lines (49 loc) · 1.88 KB
/
main_explo.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
import motifdiscovery as md
import numpy as np
import sys
#Generate data
eps = float(sys.argv[1])
p_d = float(sys.argv[2])
Jthr = float(sys.argv[3])
seed = int(sys.argv[4])
sys.stdout = open("motifs_explo_compare_eps%.2f_pd%.2f_Jthr%.2f_%d.dat" %(eps,p_d,Jthr,seed), 'w')
#eps_true = 0.0
data_explo_hmm = np.load("../Zebrafish_larvae/data_explo_hmm.npy")
data_dbsharppH_hmm = np.load("../Zebrafish_larvae/data_dbsharppH_hmm.npy")
lengths_explo_hmm = np.load("../Zebrafish_larvae/lengths_explo_hmm.npy")
lengths_dbsharppH_hmm = np.load("../Zebrafish_larvae/lengths_dbsharppH_hmm.npy")
model_fit = md.GMM_model(7)
means_ = np.load("../Zebrafish_larvae/acid_means.npy")
covars_ = np.load("../Zebrafish_larvae/acid_covars.npy")
weights_ = np.load("../Zebrafish_larvae/acid_weights.npy")
model_fit._read_params(means_,covars_,weights_)
np.set_printoptions(precision = 4, suppress = True)
print(np.argsort(model_fit.means_[:,0]))
print(model_fit.means_[np.argsort(model_fit.means_[:,0])])
print(model_fit.weights_[:,np.argsort(model_fit.means_[:,0])])
sys.stdout.flush()
lengths_explo = lengths_explo_hmm[:]
data_explo = data_explo_hmm[:np.sum(lengths_explo)]
Hexplo = -model_fit.score(data_explo,0)/len(data_explo) #entropy
Yexplo = np.exp(model_fit._compute_log_likelihood(data_explo))/np.exp(-Hexplo)
#Solve
w_thr = 1e-4
#eps = 0.0
#p_d = 0.5
p_ins = 0.2
mu = 1.0
H_beta_fac = 0
Sigma = Yexplo.shape[1]
std = 0.05
params = np.array([eps,p_d,p_ins, mu, w_thr,H_beta_fac, Jthr, Sigma, std], dtype =float)
P_w_explo, w_dict_explo = md.solve_dictionary(Yexplo,lengths_explo,params,model_fit,7)
print("\n")
#Output
print("Explo dictionary")
md.print_dict(Yexplo,w_dict_explo,P_w_explo)
print("\n")
print("non-Markovianity: Explo")
transmat_, stationary_probs_ = md.compute_transmat(Yexplo)
a,b,c = md.test_for_markovianity(Yexplo,w_dict_explo,eps,p_d,transmat_, stationary_probs_)
sys.stdout.flush()
print("\n")