Class: MeanShift

Mean shift clustering using a flat kernel.

Mean shift clustering aims to discover “blobs” in a smooth density of samples. It is a centroid-based algorithm, which works by updating candidates for centroids to be the mean of the points within a given region. These candidates are then filtered in a post-processing stage to eliminate near-duplicates to form the final set of centroids.

Seeding is performed using a binning technique for scalability.

For an example of how to use MeanShift clustering, refer to: A demo of the mean-shift clustering algorithm.

Read more in the User Guide.

Python Reference

Constructors

new MeanShift()

new MeanShift(opts?): MeanShift

Parameters

ParameterTypeDescription
opts?object-
opts.bandwidth?numberBandwidth used in the flat kernel. If not given, the bandwidth is estimated using sklearn.cluster.estimate_bandwidth; see the documentation for that function for hints on scalability (see also the Notes, below).
opts.bin_seeding?booleanIf true, initial kernel locations are not locations of all points, but rather the location of the discretized version of points, where points are binned onto a grid whose coarseness corresponds to the bandwidth. Setting this option to true will speed up the algorithm because fewer seeds will be initialized. The default value is false. Ignored if seeds argument is not undefined.
opts.cluster_all?booleanIf true, then all points are clustered, even those orphans that are not within any kernel. Orphans are assigned to the nearest kernel. If false, then orphans are given cluster label -1.
opts.max_iter?numberMaximum number of iterations, per seed point before the clustering operation terminates (for that seed point), if has not converged yet.
opts.min_bin_freq?numberTo speed up the algorithm, accept only those bins with at least min_bin_freq points as seeds.
opts.n_jobs?numberThe number of jobs to use for the computation. The following tasks benefit from the parallelization:
opts.seeds?ArrayLike[]Seeds used to initialize kernels. If not set, the seeds are calculated by clustering.get_bin_seeds with bandwidth as the grid size and default values for other parameters.

Returns MeanShift

Defined in generated/cluster/MeanShift.ts:29

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/cluster/MeanShift.ts:27
_isInitializedbooleanfalsegenerated/cluster/MeanShift.ts:26
_pyPythonBridgeundefinedgenerated/cluster/MeanShift.ts:25
idstringundefinedgenerated/cluster/MeanShift.ts:22
optsanyundefinedgenerated/cluster/MeanShift.ts:23

Accessors

cluster_centers_

Get Signature

get cluster_centers_(): Promise<ArrayLike[]>

Coordinates of cluster centers.

Returns Promise<ArrayLike[]>

Defined in generated/cluster/MeanShift.ts:294


feature_names_in_

Get Signature

get feature_names_in_(): Promise<ArrayLike>

Names of features seen during fit. Defined only when X has feature names that are all strings.

Returns Promise<ArrayLike>

Defined in generated/cluster/MeanShift.ts:390


labels_

Get Signature

get labels_(): Promise<ArrayLike>

Labels of each point.

Returns Promise<ArrayLike>

Defined in generated/cluster/MeanShift.ts:319


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit.

Returns Promise<number>

Defined in generated/cluster/MeanShift.ts:365


n_iter_

Get Signature

get n_iter_(): Promise<number>

Maximum number of iterations performed on each seed.

Returns Promise<number>

Defined in generated/cluster/MeanShift.ts:342


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/cluster/MeanShift.ts:79

Methods

dispose()

dispose(): Promise<void>

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Returns Promise<void>

Defined in generated/cluster/MeanShift.ts:130


fit()

fit(opts): Promise<any>

Perform clustering.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]Samples to cluster.
opts.y?anyNot used, present for API consistency by convention.

Returns Promise<any>

Defined in generated/cluster/MeanShift.ts:147


fit_predict()

fit_predict(opts): Promise<ArrayLike>

Perform clustering on X and returns cluster labels.

Parameters

ParameterTypeDescription
optsobject-
opts.kwargs?anyArguments to be passed to fit.
opts.X?ArrayLike[]Input data.
opts.y?anyNot used, present for API consistency by convention.

Returns Promise<ArrayLike>

Defined in generated/cluster/MeanShift.ts:184


get_metadata_routing()

get_metadata_routing(opts): Promise<any>

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Parameters

ParameterTypeDescription
optsobject-
opts.routing?anyA MetadataRequest encapsulating routing information.

Returns Promise<any>

Defined in generated/cluster/MeanShift.ts:228


init()

init(py): Promise<void>

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/cluster/MeanShift.ts:92


predict()

predict(opts): Promise<ArrayLike>

Predict the closest cluster each sample in X belongs to.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]New data to predict.

Returns Promise<ArrayLike>

Defined in generated/cluster/MeanShift.ts:262