API Reference#
- class radius_clustering.RadiusClustering(manner='approx', threshold=0.5)[source]#
Bases:
BaseEstimator
,ClusterMixin
Radius Clustering algorithm.
This class implements clustering based on the Minimum Dominating Set (MDS) problem. It can use either an exact or approximate method for solving the MDS problem.
Parameters:#
- mannerstr, optional (default=”approx”)
The method to use for solving the MDS problem. Can be “exact” or “approx”.
- thresholdfloat, optional (default=0.5)
The dissimilarity threshold to act as radius constraint for the clustering.
Attributes:#
- Xarray-like, shape (n_samples, n_features)
The input data.
- centerslist
The indices of the cluster centers.
- labels_array-like, shape (n_samples,)
The cluster labels for each point in the input data.
- effective_radiusfloat
The maximum distance between any point and its assigned cluster center.
- fit(X, y=None)[source]#
Fit the MDS clustering model to the input data.
Parameters:#
- Xarray-like, shape (n_samples, n_features)
The input data to cluster.
- yIgnored
Not used, present here for API consistency by convention.
Returns:#
- selfobject
Returns self.
Examples :#
>>> from radius_clustering import RadiusClustering >>> from sklearn import datasets >>> # Load the Iris dataset >>> iris = datasets.fetch_openml(name="iris", version=1, parser="auto") >>> X = iris["data"] # Use dictionary-style access instead of attribute access >>> rad = RadiusClustering(manner="exact", threshold=1.43).fit( ... X ... ) # Threshold set to 1.43 because it is the optimal ... # threshold for the Iris dataset >>> rad.centers_ [96, 49, 102]
For examples on common datasets and differences with kmeans, see Iris Dataset Clustering Example
- fit_predict(X, y=None)[source]#
Fit the model and return the cluster labels.
Parameters:#
- Xarray-like, shape (n_samples, n_features)
The input data to cluster.
- yIgnored
Not used, present here for API consistency by convention.
Returns:#
- labelsarray, shape (n_samples,)
The cluster labels for each point in X.