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.
Constructors
new MeanShift()
new MeanShift(
opts?):MeanShift
Parameters
| Parameter | Type | Description |
|---|---|---|
opts? | object | - |
opts.bandwidth? | number | Bandwidth 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? | boolean | If 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? | boolean | If 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? | number | Maximum number of iterations, per seed point before the clustering operation terminates (for that seed point), if has not converged yet. |
opts.min_bin_freq? | number | To speed up the algorithm, accept only those bins with at least min_bin_freq points as seeds. |
opts.n_jobs? | number | The 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
| Property | Type | Default value | Defined in |
|---|---|---|---|
_isDisposed | boolean | false | generated/cluster/MeanShift.ts:27 |
_isInitialized | boolean | false | generated/cluster/MeanShift.ts:26 |
_py | PythonBridge | undefined | generated/cluster/MeanShift.ts:25 |
id | string | undefined | generated/cluster/MeanShift.ts:22 |
opts | any | undefined | generated/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
| Parameter | Type |
|---|---|
pythonBridge | PythonBridge |
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
| Parameter | Type | Description |
|---|---|---|
opts | object | - |
opts.X? | ArrayLike[] | Samples to cluster. |
opts.y? | any | Not 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
| Parameter | Type | Description |
|---|---|---|
opts | object | - |
opts.kwargs? | any | Arguments to be passed to fit. |
opts.X? | ArrayLike[] | Input data. |
opts.y? | any | Not 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
| Parameter | Type | Description |
|---|---|---|
opts | object | - |
opts.routing? | any | A 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
| Parameter | Type |
|---|---|
py | PythonBridge |
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
| Parameter | Type | Description |
|---|---|---|
opts | object | - |
opts.X? | ArrayLike[] | New data to predict. |
Returns Promise<ArrayLike>
Defined in generated/cluster/MeanShift.ts:262