Estimate the bandwidth to use with the mean-shift algorithm.
This function takes time at least quadratic in n_samples. For large datasets, it is wise to subsample by setting n_samples. Alternatively, the parameter bandwidth can be set to a small value without estimating it.
Input points.
Should be between [0, 1] 0.5 means that the median of all pairwise distances is used.
The number of samples to use. If not given, all samples are used.
The generator used to randomly select the samples from input points for bandwidth estimation. Use an int to make the randomness deterministic. See Glossary.
The number of parallel jobs to run for neighbors search. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.
The bandwidth parameter.
>>> import numpy as np >>> from sklearn.cluster import estimate_bandwidth >>> X = np.array([[1, 1], [2, 1], [1, 0], ... [4, 7], [3, 5], [3, 6]]) >>> estimate_bandwidth(X, quantile=0.5) np.float64(1.61...)
© 2007–2025 The scikit-learn developers
Licensed under the 3-clause BSD License.
https://scikit-learn.org/1.6/modules/generated/sklearn.cluster.estimate_bandwidth.html