def DBSCAN_cluster(psi_matrix, eventid_lst, dist, minpts, metric):
# Setting logging preferences
logger = logging.getLogger(__name__)
# The metric is "cosine" works only with the algorithm "brute"
if metric == "cosine":
alg = 'brute'
else:
alg = 'auto'
try:
db = DBSCAN(eps=dist, min_samples=minpts, metric=metric, algorithm=alg).fit(psi_matrix)
labels = db.labels_
except:
logger.error("Unknown error: {}".format(sys.exc_info()))
sys.exit(1)
eventid_labels_dict = {k: v for k, v in zip(eventid_lst, labels)}
return eventid_labels_dict, labels
评论列表
文章目录