DocumentationClassesAffinityPropagation

Class: AffinityPropagation

Perform Affinity Propagation Clustering of data.

Read more in the User Guide.

Python Reference

Constructors

new AffinityPropagation()

new AffinityPropagation(opts?): AffinityPropagation

Parameters

ParameterTypeDescription
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?numberNumber of iterations with no change in the number of estimated clusters that stops the convergence.
opts.copy?booleanMake a copy of input data.
opts.damping?numberDamping 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?numberMaximum number of iterations.
opts.preference?number | [ArrayLikePreferences 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?numberPseudo-random number generator to control the starting state. Use an int for reproducible results across function calls. See the Glossary.
opts.verbose?booleanWhether to be verbose.

Returns AffinityPropagation

Defined in generated/cluster/AffinityPropagation.ts:23

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/cluster/AffinityPropagation.ts:21
_isInitializedbooleanfalsegenerated/cluster/AffinityPropagation.ts:20
_pyPythonBridgeundefinedgenerated/cluster/AffinityPropagation.ts:19
idstringundefinedgenerated/cluster/AffinityPropagation.ts:16
optsanyundefinedgenerated/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

ParameterType
pythonBridgePythonBridge

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

ParameterTypeDescription
optsobject-
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?anyNot 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

ParameterTypeDescription
optsobject-
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?anyNot 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

ParameterTypeDescription
optsobject-
opts.routing?anyA 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

ParameterType
pyPythonBridge

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

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeNew 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