data = np.concatenate((data1[:, :], data2[:, :]), axis=0)

np.random.seed(1)

num_of_cells = len(data[:, 0])
l = 90
y = np.zeros(num_of_cells, dtype=int)
M = 2
S = 4 # 2: 4 MHMM, 3 oMHMM; 4: 4 MHMM, 6 oMHMM
lengths = (np.ones(num_of_cells, dtype=int) * l).tolist()
###################################################################################################
mhmm = oMHMM.SpaMHMM(epsilon=.0000001, n_nodes=1,
                       mix_dim=M,
                       n_components=S,
                       n_features=l,
                       graph=None,
                       n_iter=100,
                       verbose=True,
                       name='mhmm')
mhmm.fit(data.flatten()[:, np.newaxis], y, lengths)
pi_nk, transitions = mhmm._compute_mixture_posteriors(data.flatten()[:, np.newaxis], y, lengths)

print(transitions.reshape(M, S, S))

print(np.exp(pi_nk))

predicted_cluster = []
label_0 = [0 for i in range(len(data1[:, 0]))]
label_1 = [1 for i in range(len(data2[:, 0]))]
for n in range(num_of_cells):
    cell = np.float64(pi_nk[n])
Пример #2
0
# plot(data[18:, :], 'primary cells', 'blue')
#plot(data[15, :], 'cell M-67', 'black')
#plot(data[35:, :], 'cell P-8', 'blue')

np.random.seed(1)

l = 808
y = np.zeros(36, dtype=int)
M = 2
S = 3
lengths = (np.ones(36, dtype=int) * l).tolist()
mhmm = spamhmm_orthogonal_init_A.SpaMHMM(epsilon=0,
                                         n_nodes=1,
                                         mix_dim=M,
                                         n_components=S,
                                         n_features=l,
                                         graph=None,
                                         n_iter=100,
                                         verbose=True,
                                         name='mhmm')
mhmm.fit(data.flatten()[:, np.newaxis], y, lengths)
pi_nk, transitions = mhmm._compute_mixture_posteriors(
    data.flatten()[:, np.newaxis], y, lengths)

print(transitions.reshape(M, S, S))

print(np.exp(pi_nk))

predicted_cluster = []
label = [
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,