tp_apprentissage/divers/clustering_metrics_evaluation.py
2020-11-10 21:38:27 +01:00

13 lines
No EOL
445 B
Python

def eps_dbscan_hdbscan(data, **kwargs):
from sklearn.neighbors import NearestNeighbors
from numpy import sort
import matplotlib.pyplot as plt
neigh = NearestNeighbors(n_neighbors=2)
nbrs = neigh.fit(data)
distances, _ = nbrs.kneighbors(data)
distances = sort(distances, axis=0)
distances = distances[:, 1]
plt.plot(distances)
if "fig_title" in kwargs:
plt.title(kwargs["fig_title"])
plt.show()