milia.cluster.models.dbscan#
DBSCAN, with eps chosen from the k-distance elbow.
Functions
|
Eps at the elbow of the sorted k-distance curve (Ester et al., 1996). |
Classes
|
Density-based clustering; points in no dense region are noise ( |
|
Validated hyperparameters of the DBSCAN clusterer. |
- milia.cluster.models.dbscan.elbow(X, min_samples)#
Eps at the elbow of the sorted k-distance curve (Ester et al., 1996).
The k-distance of each point is its distance to its
min_samples-th neighbour; the elbow is the point of largest second difference of the sorted curve.- Parameters:
- Return type:
- Returns:
A positive eps.
Examples
>>> import numpy as np >>> X = np.r_[np.zeros((20, 2)), np.full((20, 2), 9.0)] + np.random.default_rng(0).normal( ... scale=0.2, size=(40, 2) ... ) >>> 0 < elbow(X, 5) < 9 True
- class milia.cluster.models.dbscan.DBSCAN(eps=None, min_samples=5, metric='euclidean')#
Bases:
BaseClustererDensity-based clustering; points in no dense region are noise (
-1).- Parameters:
Examples
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> X = np.repeat(np.array([[0.0, 0.0], [6.0, 6.0], [0.0, 6.0]]), 20, axis=0) + rng.normal( ... scale=0.4, size=(60, 2) ... ) >>> DBSCAN(min_samples=5).fit(X).n_clusters_ 3
- class milia.cluster.models.dbscan.DBSCANConfig(*, name='dbscan', kind='clusterer', space=SearchSpace(min_samples=(3, 50)), eps=None, min_samples=5, metric='euclidean')#
Bases:
BaseModelConfigValidated hyperparameters of the DBSCAN clusterer.
Fields mirror
DBSCAN’s constructor;spaceis the default Optuna search space. Build the clusterer withmake("clusterer", "dbscan", ...)orDBSCAN(**config.params()).Examples
>>> DBSCANConfig().name 'dbscan'