if sum(np.isnan(perf) == False) == 0: best_e = 10 * max(e) best_x = 0.08 best_m = 5 else: best_e = e[np.nanargmax(perf)] best_x = x[np.nanargmax(perf)] best_m = m[np.nanargmax(perf)] algorithm = select_algorithm(a_name, best_m, best_e, int(dim_m * 0.05), best_x) y = algorithm.fit_predict(X) cc = cr.cluster_context(X, y) gv = cr.gval(cc) if p_outliers == False: y = cr.reassign_outliers(X, y, 0, cc.centroids, gv.extR).astype(int) S, CH, DB = cr.other_validations(X, y) rc = cr.refinement_context(X, y, cc, gv) AMI = adjusted_mutual_info_score(ygt, y) df_val.loc[(d_name, a_name, 'Best'), 'Grex'] = gv.Grex df_val.loc[(d_name, a_name, 'Best'), 'Gstr'] = gv.Gstr df_val.loc[(d_name, a_name, 'Best'), 'Gmin'] = gv.Gmin df_val.loc[(d_name, a_name, 'Best'), 'Sil'] = S df_val.loc[(d_name, a_name, 'Best'), 'CH'] = CH df_val.loc[(d_name, a_name, 'Best'), 'DB'] = DB
clustering_algorithms = ['mkm'] for a_name in clustering_algorithms: print("Clustering with wrong parameters:", a_name) start = time.time() k = 10 + p_n_clusters algorithm = select_algorithm(a_name, k) y = algorithm.fit_predict(X) end = time.time() T = (end - start) cc = cr2.cluster_context(X, y) gv = cr2.gval(cc) if p_outliers == False: y = cr2.reassign_outliers(X, y, 0, cc.centroids, gv.extR).astype(int) S, CH, DB = cr2.other_validations(X, y) rc = cr2.refinement_context(X, y, cc, gv) AMI = adjusted_mutual_info_score(ygt, y) df_val.loc[(d_name, a_name, 'Normal'), 'Grex'] = gv.Grex df_val.loc[(d_name, a_name, 'Normal'), 'Gstr'] = gv.Gstr df_val.loc[(d_name, a_name, 'Normal'), 'Gmin'] = gv.Gmin df_val.loc[(d_name, a_name, 'Normal'), 'Sil'] = S df_val.loc[(d_name, a_name, 'Normal'), 'CH'] = CH df_val.loc[(d_name, a_name, 'Normal'), 'DB'] = DB