Documentation
Classes
FeatureAgglomeration

FeatureAgglomeration

Agglomerate features.

Recursively merges pair of clusters of features.

Read more in the User Guide.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new FeatureAgglomeration(opts?: object): FeatureAgglomeration;

Parameters

NameTypeDescription
opts?object-
opts.affinity?stringThe metric to use when calculating distance between instances in a feature array. If metric is a string or callable, it must be one of the options allowed by sklearn.metrics.pairwise\_distances for its metric parameter. If linkage is “ward”, only “euclidean” is accepted. If “precomputed”, a distance matrix (instead of a similarity matrix) is needed as input for the fit method. Default Value 'euclidean'
opts.compute_distances?booleanComputes distances between clusters even if distance\_threshold is not used. This can be used to make dendrogram visualization, but introduces a computational and memory overhead. Default Value false
opts.compute_full_tree?boolean | "auto"Stop early the construction of the tree at n\_clusters. This is useful to decrease computation time if the number of clusters is not small compared to the number of features. This option is useful only when specifying a connectivity matrix. Note also that when varying the number of clusters and using caching, it may be advantageous to compute the full tree. It must be true if distance\_threshold is not undefined. By default compute\_full\_tree is “auto”, which is equivalent to true when distance\_threshold is not undefined or that n\_clusters is inferior to the maximum between 100 or 0.02 \* n\_samples. Otherwise, “auto” is equivalent to false. Default Value 'auto'
opts.connectivity?ArrayLikeConnectivity matrix. Defines for each feature the neighboring features following a given structure of the data. This can be a connectivity matrix itself or a callable that transforms the data into a connectivity matrix, such as derived from kneighbors\_graph. Default is undefined, i.e, the hierarchical clustering algorithm is unstructured.
opts.distance_threshold?numberThe linkage distance threshold at or above which clusters will not be merged. If not undefined, n\_clusters must be undefined and compute\_full\_tree must be true.
opts.linkage?"ward" | "complete" | "average" | "single"Which linkage criterion to use. The linkage criterion determines which distance to use between sets of features. The algorithm will merge the pairs of cluster that minimize this criterion. Default Value 'ward'
opts.memory?stringUsed to cache the output of the computation of the tree. By default, no caching is done. If a string is given, it is the path to the caching directory.
opts.metric?stringMetric used to compute the linkage. Can be “euclidean”, “l1”, “l2”, “manhattan”, “cosine”, or “precomputed”. If set to undefined then “euclidean” is used. If linkage is “ward”, only “euclidean” is accepted. If “precomputed”, a distance matrix is needed as input for the fit method.
opts.n_clusters?numberThe number of clusters to find. It must be undefined if distance\_threshold is not undefined. Default Value 2
opts.pooling_func?anyThis combines the values of agglomerated features into a single value, and should accept an array of shape [M, N] and the keyword argument axis=1, and reduce it to an array of size [M].

Returns

FeatureAgglomeration

Defined in: generated/cluster/FeatureAgglomeration.ts:25 (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/FeatureAgglomeration.ts:157 (opens in a new tab)

fit()

Fit the hierarchical clustering on the data.

Signature

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

Parameters

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

Returns

Promise<any>

Defined in: generated/cluster/FeatureAgglomeration.ts:174 (opens in a new tab)

fit_transform()

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit\_params and returns a transformed version of X.

Signature

fit_transform(opts: object): Promise<any[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Input samples.
opts.fit_params?anyAdditional fit parameters.
opts.y?ArrayLikeTarget values (undefined for unsupervised transformations).

Returns

Promise<any[]>

Defined in: generated/cluster/FeatureAgglomeration.ts:216 (opens in a new tab)

get_feature_names_out()

Get output feature names for transformation.

The feature names out will prefixed by the lowercased class name. For example, if the transformer outputs 3 features, then the feature names out are: \["class\_name0", "class\_name1", "class\_name2"\].

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.input_features?anyOnly used to validate feature names with the names seen in fit.

Returns

Promise<any>

Defined in: generated/cluster/FeatureAgglomeration.ts:269 (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/FeatureAgglomeration.ts:309 (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/FeatureAgglomeration.ts:103 (opens in a new tab)

inverse_transform()

Inverse the transformation and return a vector of size n\_features.

Signature

inverse_transform(opts: object): Promise<ArrayLike[]>;

Parameters

NameTypeDescription
optsobject-
opts.Xred?anyUse Xt instead.
opts.Xt?ArrayLike[]The values to be assigned to each cluster of samples.

Returns

Promise<ArrayLike[]>

Defined in: generated/cluster/FeatureAgglomeration.ts:347 (opens in a new tab)

set_output()

Set output container.

See Introducing the set_output API for an example on how to use the API.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.transform?"default" | "pandas"Configure output of transform and fit\_transform.

Returns

Promise<any>

Defined in: generated/cluster/FeatureAgglomeration.ts:394 (opens in a new tab)

transform()

Transform a new matrix using the built clustering.

Signature

transform(opts: object): Promise<ArrayLike[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]A M by N array of M observations in N dimensions or a length M array of M one-dimensional observations.

Returns

Promise<ArrayLike[]>

Defined in: generated/cluster/FeatureAgglomeration.ts:431 (opens in a new tab)

Properties

_isDisposed

boolean = false

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

_isInitialized

boolean = false

Defined in: generated/cluster/FeatureAgglomeration.ts:22 (opens in a new tab)

_py

PythonBridge

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

id

string

Defined in: generated/cluster/FeatureAgglomeration.ts:18 (opens in a new tab)

opts

any

Defined in: generated/cluster/FeatureAgglomeration.ts:19 (opens in a new tab)

Accessors

children_

The children of each non-leaf node. Values less than n\_features correspond to leaves of the tree which are the original samples. A node i greater than or equal to n\_features is a non-leaf node and has children children\_\[i \- n\_features\]. Alternatively at the i-th iteration, children[i][0] and children[i][1] are merged to form node n\_features + i.

Signature

children_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/cluster/FeatureAgglomeration.ts:630 (opens in a new tab)

distances_

Distances between nodes in the corresponding place in children\_. Only computed if distance\_threshold is used or compute\_distances is set to true.

Signature

distances_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/cluster/FeatureAgglomeration.ts:657 (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/FeatureAgglomeration.ts:603 (opens in a new tab)

labels_

Cluster labels for each feature.

Signature

labels_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/cluster/FeatureAgglomeration.ts:495 (opens in a new tab)

n_clusters_

The number of clusters found by the algorithm. If distance\_threshold=None, it will be equal to the given n\_clusters.

Signature

n_clusters_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/cluster/FeatureAgglomeration.ts:468 (opens in a new tab)

n_connected_components_

The estimated number of connected components in the graph.

Signature

n_connected_components_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/cluster/FeatureAgglomeration.ts:549 (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/FeatureAgglomeration.ts:576 (opens in a new tab)

n_leaves_

Number of leaves in the hierarchical tree.

Signature

n_leaves_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/cluster/FeatureAgglomeration.ts:522 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

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

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/cluster/FeatureAgglomeration.ts:94 (opens in a new tab)