AffinityPropagation
Perform Affinity Propagation Clustering of data.
Read more in the User Guide.
Python Reference (opens in a new tab)
Constructors
constructor()
Signature
new AffinityPropagation(opts?: object): AffinityPropagation;
Parameters
Name | Type | Description |
---|---|---|
opts? | object | - |
opts.affinity? | "euclidean" | "precomputed" | Which affinity to use. At the moment ‘precomputed’ and euclidean are supported. ‘euclidean’ uses the negative squared euclidean distance between points. Default Value 'euclidean' |
opts.convergence_iter? | number | Number of iterations with no change in the number of estimated clusters that stops the convergence. Default Value 15 |
opts.copy? | boolean | Make a copy of input data. Default Value true |
opts.damping? | number | Damping factor in the range \0.5, 1.0) is the extent to which the current value is maintained relative to incoming values (weighted 1 - damping). This in order to avoid numerical oscillations when updating these values (messages). Default Value 0.5 |
opts.max_iter? | number | Maximum number of iterations. Default Value 200 |
opts.preference? | number | [ArrayLike | Preferences for each point - points with larger values of preferences are more likely to be chosen as exemplars. The number of exemplars, ie of clusters, is influenced by the input preferences value. If the preferences are not passed as arguments, they will be set to the median of the input similarities. |
opts.random_state? | number | Pseudo-random number generator to control the starting state. Use an int for reproducible results across function calls. See the Glossary. |
opts.verbose? | boolean | Whether to be verbose. Default Value false |
Returns
Defined in: generated/cluster/AffinityPropagation.ts:23 (opens in a new tab)
Properties
_isDisposed
boolean
=false
Defined in: generated/cluster/AffinityPropagation.ts:21 (opens in a new tab)
_isInitialized
boolean
=false
Defined in: generated/cluster/AffinityPropagation.ts:20 (opens in a new tab)
_py
PythonBridge
Defined in: generated/cluster/AffinityPropagation.ts:19 (opens in a new tab)
id
string
Defined in: generated/cluster/AffinityPropagation.ts:16 (opens in a new tab)
opts
any
Defined in: generated/cluster/AffinityPropagation.ts:17 (opens in a new tab)
Accessors
affinity_matrix_
Stores the affinity matrix used in fit
.
Signature
affinity_matrix_(): Promise<ArrayLike[]>;
Returns
Promise
<ArrayLike
[]>
Defined in: generated/cluster/AffinityPropagation.ts:360 (opens in a new tab)
cluster_centers_
Cluster centers (if affinity != precomputed
).
Signature
cluster_centers_(): Promise<ArrayLike[]>;
Returns
Promise
<ArrayLike
[]>
Defined in: generated/cluster/AffinityPropagation.ts:306 (opens in a new tab)
cluster_centers_indices_
Indices of cluster centers.
Signature
cluster_centers_indices_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/cluster/AffinityPropagation.ts:279 (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/AffinityPropagation.ts:441 (opens in a new tab)
labels_
Labels of each point.
Signature
labels_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/cluster/AffinityPropagation.ts:333 (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/AffinityPropagation.ts:414 (opens in a new tab)
n_iter_
Number of iterations taken to converge.
Signature
n_iter_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/cluster/AffinityPropagation.ts:387 (opens in a new tab)
py
Signature
py(): PythonBridge;
Returns
PythonBridge
Defined in: generated/cluster/AffinityPropagation.ts:80 (opens in a new tab)
Signature
py(pythonBridge: PythonBridge): void;
Parameters
Name | Type |
---|---|
pythonBridge | PythonBridge |
Returns
void
Defined in: generated/cluster/AffinityPropagation.ts:84 (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/AffinityPropagation.ts:145 (opens in a new tab)
fit()
Fit the clustering from features, or affinity matrix.
Signature
fit(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Training instances to cluster, or similarities / affinities between instances if affinity='precomputed' . If a sparse feature matrix is provided, it will be converted into a sparse csr\_matrix . |
opts.y? | any | Not used, present here for API consistency by convention. |
Returns
Promise
<any
>
Defined in: generated/cluster/AffinityPropagation.ts:162 (opens in a new tab)
fit_predict()
Fit clustering from features/affinity matrix; return cluster labels.
Signature
fit_predict(opts: object): Promise<ArrayLike>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Training instances to cluster, or similarities / affinities between instances if affinity='precomputed' . If a sparse feature matrix is provided, it will be converted into a sparse csr\_matrix . |
opts.y? | any | Not used, present here for API consistency by convention. |
Returns
Promise
<ArrayLike
>
Defined in: generated/cluster/AffinityPropagation.ts:202 (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
Name | Type |
---|---|
py | PythonBridge |
Returns
Promise
<void
>
Defined in: generated/cluster/AffinityPropagation.ts:93 (opens in a new tab)
predict()
Predict the closest cluster each sample in X belongs to.
Signature
predict(opts: object): Promise<ArrayLike>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | New data to predict. If a sparse matrix is provided, it will be converted into a sparse csr\_matrix . |
Returns
Promise
<ArrayLike
>
Defined in: generated/cluster/AffinityPropagation.ts:244 (opens in a new tab)