コード例 #1
0
#===========================================#

r = np.array([2, 1])
numobs = len(y)
k = [n_clusters]

seed = 1
init_seed = 2

eps = 1E-05
it = 50
maxstep = 100

prince_init = dim_reduce_init(y, n_clusters, k, r, nj, var_distrib, seed = None,\
                              use_famd=True)
m, pred = misc(labels_oh, prince_init['classes'], True)
print(m)
print(confusion_matrix(labels_oh, pred))
print(silhouette_score(dm, pred, metric='precomputed'))
'''
init = prince_init
seed = None
y = y_np
perform_selec = False
os.chdir('C:/Users/rfuchs/Documents/GitHub/M1DGMM')
'''


out = M1DGMM(y_np, 'auto', r, k, prince_init, var_distrib, nj, it,\
             eps, maxstep, seed, perform_selec = False)
m, pred = misc(labels_oh, out['classes'], True)
コード例 #2
0
r = {'c': [nb_cont], 'd': [3], 't': [2, 1]}
k = {'c': [1], 'd': [2], 't': [n_clusters, 1]}

seed = 1
init_seed = 2

eps = 1E-05
it = 15
maxstep = 100

# MCA init
prince_init = dim_reduce_init(y, n_clusters, k, r, nj, var_distrib, seed=None)

out = MDGMM(y_np, n_clusters, r, k, prince_init, var_distrib, nj, it, eps,\
            maxstep, seed, perform_selec = False)
m, pred = misc(labels_oh, out['classes'], True)
micro = precision_score(labels_oh, pred, average='micro')
macro = precision_score(labels_oh, pred, average='macro')

print('Silhouette', silhouette_score(dm, pred, metric='precomputed'))
print('Micro', micro)
print('Macro', macro)

#===========================================#
# Final plotting
#===========================================#

# Plot the final groups

import matplotlib
import matplotlib.pyplot as plt