Toggle Menu
Prev Up Next

scikit-learn 1.3.2
Other versions

Please cite us if you use the software.

# `sklearn.cluster`.estimate_bandwidth

sklearn.cluster.estimate_bandwidth(X, *, quantile=0.3, n_samples=None, random_state=0, n_jobs=None)

  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.

  Parameters:
    X array-like of shape (n_samples, n_features)

      Input points.

    quantile float, default=0.3

      Should be between [0, 1] 0.5 means that the median of all pairwise distances is used.

    n_samples int, default=None

      The number of samples to use. If not given, all samples are used.

    random_state int, RandomState instance, default=None

      The generator used to randomly select the samples from input points for bandwidth estimation. Use an int to make the randomness deterministic. See Glossary.

    n_jobs int, default=None

      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.

  Returns:
    bandwidth float

      The bandwidth parameter.

## Examples using `sklearn.cluster.estimate_bandwidth`

A demo of the mean-shift clustering algorithm

A demo of the mean-shift clustering algorithm

Comparing different clustering algorithms on toy datasets

Comparing different clustering algorithms on toy datasets