Class: FeatureAgglomeration
Agglomerate features.
Recursively merges pair of clusters of features.
Read more in the User Guide.
Constructors
new FeatureAgglomeration()
new FeatureAgglomeration(
opts
?):FeatureAgglomeration
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.compute_distances ? | boolean | Computes 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. |
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 . |
opts.connectivity ? | ArrayLike | Connectivity 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 ? | number | The 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. |
opts.memory ? | string | Used 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 ? | string | Metric used to compute the linkage. Can be “euclidean”, “l1”, “l2”, “manhattan”, “cosine”, or “precomputed”. If linkage is “ward”, only “euclidean” is accepted. If “precomputed”, a distance matrix is needed as input for the fit method. |
opts.n_clusters ? | number | The number of clusters to find. It must be undefined if distance_threshold is not undefined . |
opts.pooling_func ? | any | This 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
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/cluster/FeatureAgglomeration.ts:23 |
_isInitialized | boolean | false | generated/cluster/FeatureAgglomeration.ts:22 |
_py | PythonBridge | undefined | generated/cluster/FeatureAgglomeration.ts:21 |
id | string | undefined | generated/cluster/FeatureAgglomeration.ts:18 |
opts | any | undefined | generated/cluster/FeatureAgglomeration.ts:19 |
Accessors
children_
Get Signature
get children_():
Promise
<ArrayLike
[]>
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
.
Returns Promise
<ArrayLike
[]>
Defined in generated/cluster/FeatureAgglomeration.ts:598
distances_
Get Signature
get distances_():
Promise
<ArrayLike
>
Distances between nodes in the corresponding place in children_
. Only computed if distance_threshold
is used or compute_distances
is set to true
.
Returns Promise
<ArrayLike
>
Defined in generated/cluster/FeatureAgglomeration.ts:625
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/FeatureAgglomeration.ts:571
labels_
Get Signature
get labels_():
Promise
<any
>
Cluster labels for each feature.
Returns Promise
<any
>
Defined in generated/cluster/FeatureAgglomeration.ts:463
n_clusters_
Get Signature
get n_clusters_():
Promise
<number
>
The number of clusters found by the algorithm. If distance_threshold=None
, it will be equal to the given n_clusters
.
Returns Promise
<number
>
Defined in generated/cluster/FeatureAgglomeration.ts:436
n_connected_components_
Get Signature
get n_connected_components_():
Promise
<number
>
The estimated number of connected components in the graph.
Returns Promise
<number
>
Defined in generated/cluster/FeatureAgglomeration.ts:517
n_features_in_
Get Signature
get n_features_in_():
Promise
<number
>
Number of features seen during fit.
Returns Promise
<number
>
Defined in generated/cluster/FeatureAgglomeration.ts:544
n_leaves_
Get Signature
get n_leaves_():
Promise
<number
>
Number of leaves in the hierarchical tree.
Returns Promise
<number
>
Defined in generated/cluster/FeatureAgglomeration.ts:490
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/FeatureAgglomeration.ts:85
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/FeatureAgglomeration.ts:141
fit()
fit(
opts
):Promise
<any
>
Fit the hierarchical clustering on the data.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | The data. |
opts.y ? | any | Not used, present here for API consistency by convention. |
Returns Promise
<any
>
Defined in generated/cluster/FeatureAgglomeration.ts:158
fit_transform()
fit_transform(
opts
):Promise
<any
[]>
Fit to data, then transform it.
Fits transformer to X
and y
with optional parameters fit_params
and returns a transformed version of X
.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.fit_params ? | any | Additional fit parameters. |
opts.X ? | ArrayLike [] | Input samples. |
opts.y ? | ArrayLike | Target values (undefined for unsupervised transformations). |
Returns Promise
<any
[]>
Defined in generated/cluster/FeatureAgglomeration.ts:199
get_feature_names_out()
get_feature_names_out(
opts
):Promise
<any
>
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"\]
.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.input_features ? | any | Only used to validate feature names with the names seen in fit . |
Returns Promise
<any
>
Defined in generated/cluster/FeatureAgglomeration.ts:247
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/FeatureAgglomeration.ts:285
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/FeatureAgglomeration.ts:98
inverse_transform()
inverse_transform(
opts
):Promise
<ArrayLike
[]>
Inverse the transformation and return a vector of size n_features
.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | The values to be assigned to each cluster of samples. |
opts.Xt ? | ArrayLike [] | The values to be assigned to each cluster of samples. |
Returns Promise
<ArrayLike
[]>
Defined in generated/cluster/FeatureAgglomeration.ts:321
set_output()
set_output(
opts
):Promise
<any
>
Set output container.
See Introducing the set_output API for an example on how to use the API.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.transform ? | "default" | "pandas" | "polars" | Configure output of transform and fit_transform . |
Returns Promise
<any
>
Defined in generated/cluster/FeatureAgglomeration.ts:364
transform()
transform(
opts
):Promise
<ArrayLike
[]>
Transform a new matrix using the built clustering.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
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
[]>