def cluster_analysis(dpsi, psivec, sig_threshold, dpsi_threshold, eps, minpts, metric, indexes, clustering,
separation, output):
path = os.path.dirname(os.path.realpath(dpsi))
os.chdir(path)
psi_matrix, eventid_lst = process_cluster_input(dpsi, psivec, sig_threshold, dpsi_threshold, indexes)
if(clustering=="DBSCAN"):
eventid_labels_dict, labels = DBSCAN_cluster(psi_matrix, eventid_lst, eps, minpts, metric)
#eventid_labels_dict are the labels of the clustering for eacg event
write_averaged_cluster_output(psi_matrix, eventid_lst, eventid_labels_dict, output)
calculate_cluster_scores(psi_matrix, labels, output)
else:
#OPTICS
points_list = create_points_list(psi_matrix, eventid_lst) #Transform the points on psi_matrix to Points from optics.py
optics = Optics(points_list, eps, minpts) # Maximum radius to be considered, cluster size >= 2 points
optics.run() # run the algorithm
clusters = optics.cluster(separation) # minimum threshold for clustering (upper limit to separate the clusters)
eventid_labels_dict, labels = generate_labels(clusters, eventid_lst)
write_averaged_cluster_output(psi_matrix, eventid_lst, eventid_labels_dict, output)
calculate_cluster_scores(psi_matrix, labels, output)
评论列表
文章目录