Class: AffinityPropagation
Perform Affinity Propagation Clustering of data.
Read more in the User Guide.
Constructors
new AffinityPropagation()
new AffinityPropagation(
opts
?):AffinityPropagation
Parameters
Parameter | 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. |
opts.convergence_iter ? | number | Number of iterations with no change in the number of estimated clusters that stops the convergence. |
opts.copy ? | boolean | Make a copy of input data. |
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). |
opts.max_iter ? | number | Maximum number of iterations. |
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. |
Returns AffinityPropagation
Defined in generated/cluster/AffinityPropagation.ts:23
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/cluster/AffinityPropagation.ts:21 |
_isInitialized | boolean | false | generated/cluster/AffinityPropagation.ts:20 |
_py | PythonBridge | undefined | generated/cluster/AffinityPropagation.ts:19 |
id | string | undefined | generated/cluster/AffinityPropagation.ts:16 |
opts | any | undefined | generated/cluster/AffinityPropagation.ts:17 |
Accessors
affinity_matrix_
Get Signature
get affinity_matrix_():
Promise
<ArrayLike
[]>
Stores the affinity matrix used in fit
.
Returns Promise
<ArrayLike
[]>
Defined in generated/cluster/AffinityPropagation.ts:386
cluster_centers_
Get Signature
get cluster_centers_():
Promise
<ArrayLike
[]>
Cluster centers (if affinity != precomputed
).
Returns Promise
<ArrayLike
[]>
Defined in generated/cluster/AffinityPropagation.ts:332
cluster_centers_indices_
Get Signature
get cluster_centers_indices_():
Promise
<ArrayLike
>
Indices of cluster centers.
Returns Promise
<ArrayLike
>
Defined in generated/cluster/AffinityPropagation.ts:305
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/AffinityPropagation.ts:467
labels_
Get Signature
get labels_():
Promise
<ArrayLike
>
Labels of each point.
Returns Promise
<ArrayLike
>
Defined in generated/cluster/AffinityPropagation.ts:359
n_features_in_
Get Signature
get n_features_in_():
Promise
<number
>
Number of features seen during fit.
Returns Promise
<number
>
Defined in generated/cluster/AffinityPropagation.ts:440
n_iter_
Get Signature
get n_iter_():
Promise
<number
>
Number of iterations taken to converge.
Returns Promise
<number
>
Defined in generated/cluster/AffinityPropagation.ts:413
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/AffinityPropagation.ts:80
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/AffinityPropagation.ts:136
fit()
fit(
opts
):Promise
<any
>
Fit the clustering from features, or affinity matrix.
Parameters
Parameter | 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:153
fit_predict()
fit_predict(
opts
):Promise
<ArrayLike
>
Fit clustering from features/affinity matrix; return cluster labels.
Parameters
Parameter | 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:192
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/AffinityPropagation.ts:235
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/AffinityPropagation.ts:93
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. If a sparse matrix is provided, it will be converted into a sparse csr_matrix . |
Returns Promise
<ArrayLike
>
Defined in generated/cluster/AffinityPropagation.ts:271