Documentation
Classes
MeanShift

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.

Read more in the User Guide.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new MeanShift(opts?: object): MeanShift;

Parameters

NameTypeDescription
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. Default Value false
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. Default Value true
opts.max_iter?numberMaximum number of iterations, per seed point before the clustering operation terminates (for that seed point), if has not converged yet. Default Value 300
opts.min_bin_freq?numberTo speed up the algorithm, accept only those bins with at least min_bin_freq points as seeds. Default Value 1
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:27 (opens in a new tab)

Methods

dispose()

Disposes of the underlying Python resources.

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

Signature

dispose(): Promise<void>;

Returns

Promise<void>

Defined in: generated/cluster/MeanShift.ts:137 (opens in a new tab)

fit()

Perform clustering.

Signature

fit(opts: object): Promise<any>;

Parameters

NameTypeDescription
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:154 (opens in a new tab)

fit_predict()

Perform clustering on X and returns cluster labels.

Signature

fit_predict(opts: object): Promise<ArrayLike>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Input data.
opts.y?anyNot used, present for API consistency by convention.

Returns

Promise<ArrayLike>

Defined in: generated/cluster/MeanShift.ts:192 (opens in a new tab)

get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Signature

get_metadata_routing(opts: object): Promise<any>;

Parameters

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

Returns

Promise<any>

Defined in: generated/cluster/MeanShift.ts:232 (opens in a new tab)

init()

Initializes the underlying Python resources.

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

Signature

init(py: PythonBridge): Promise<void>;

Parameters

NameType
pyPythonBridge

Returns

Promise<void>

Defined in: generated/cluster/MeanShift.ts:90 (opens in a new tab)

predict()

Predict the closest cluster each sample in X belongs to.

Signature

predict(opts: object): Promise<ArrayLike>;

Parameters

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

Returns

Promise<ArrayLike>

Defined in: generated/cluster/MeanShift.ts:267 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/cluster/MeanShift.ts:25 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/cluster/MeanShift.ts:24 (opens in a new tab)

_py

PythonBridge

Defined in: generated/cluster/MeanShift.ts:23 (opens in a new tab)

id

string

Defined in: generated/cluster/MeanShift.ts:20 (opens in a new tab)

opts

any

Defined in: generated/cluster/MeanShift.ts:21 (opens in a new tab)

Accessors

cluster_centers_

Coordinates of cluster centers.

Signature

cluster_centers_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/cluster/MeanShift.ts:300 (opens in a new tab)

feature_names_in_

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

Signature

feature_names_in_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/cluster/MeanShift.ts:396 (opens in a new tab)

labels_

Labels of each point.

Signature

labels_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/cluster/MeanShift.ts:325 (opens in a new tab)

n_features_in_

Number of features seen during fit.

Signature

n_features_in_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/cluster/MeanShift.ts:371 (opens in a new tab)

n_iter_

Maximum number of iterations performed on each seed.

Signature

n_iter_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/cluster/MeanShift.ts:348 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/cluster/MeanShift.ts:77 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/cluster/MeanShift.ts:81 (opens in a new tab)