class sklearn.cluster.FeatureAgglomeration(n_clusters=2, affinity=’euclidean’, memory=None, connectivity=None, compute_full_tree=’auto’, linkage=’ward’, pooling_func=<function mean>)
[source]
Agglomerate features.
Similar to AgglomerativeClustering, but recursively merges features instead of samples.
Read more in the User Guide.
Parameters: 


Attributes: 

>>> import numpy as np >>> from sklearn import datasets, cluster >>> digits = datasets.load_digits() >>> images = digits.images >>> X = np.reshape(images, (len(images), 1)) >>> agglo = cluster.FeatureAgglomeration(n_clusters=32) >>> agglo.fit(X) FeatureAgglomeration(affinity='euclidean', compute_full_tree='auto', connectivity=None, linkage='ward', memory=None, n_clusters=32, pooling_func=...) >>> X_reduced = agglo.transform(X) >>> X_reduced.shape (1797, 32)
fit (X[, y])  Fit the hierarchical clustering on the data 
fit_transform (X[, y])  Fit to data, then transform it. 
get_params ([deep])  Get parameters for this estimator. 
inverse_transform (Xred)  Inverse the transformation. 
pooling_func (a[, axis, dtype, out, keepdims])  Compute the arithmetic mean along the specified axis. 
set_params (**params)  Set the parameters of this estimator. 
transform (X)  Transform a new matrix using the built clustering 
__init__(n_clusters=2, affinity=’euclidean’, memory=None, connectivity=None, compute_full_tree=’auto’, linkage=’ward’, pooling_func=<function mean>)
[source]
fit(X, y=None, **params)
[source]
Fit the hierarchical clustering on the data
Parameters: 


Returns: 

fit_transform(X, y=None, **fit_params)
[source]
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: 


Returns: 

get_params(deep=True)
[source]
Get parameters for this estimator.
Parameters: 


Returns: 

inverse_transform(Xred)
[source]
Inverse the transformation. Return a vector of size nb_features with the values of Xred assigned to each group of features
Parameters: 


Returns: 

pooling_func(a, axis=None, dtype=None, out=None, keepdims=<no value>)
[source]
Compute the arithmetic mean along the specified axis.
Returns the average of the array elements. The average is taken over the flattened array by default, otherwise over the specified axis. float64
intermediate and return values are used for integer inputs.
Parameters: 


Returns: 

See also
average
std
, var
, nanmean
, nanstd
, nanvar
The arithmetic mean is the sum of the elements along the axis divided by the number of elements.
Note that for floatingpoint input, the mean is computed using the same precision the input has. Depending on the input data, this can cause the results to be inaccurate, especially for float32
(see example below). Specifying a higherprecision accumulator using the dtype
keyword can alleviate this issue.
By default, float16
results are computed using float32
intermediates for extra precision.
>>> a = np.array([[1, 2], [3, 4]]) >>> np.mean(a) 2.5 >>> np.mean(a, axis=0) array([ 2., 3.]) >>> np.mean(a, axis=1) array([ 1.5, 3.5])
In single precision, mean
can be inaccurate:
>>> a = np.zeros((2, 512*512), dtype=np.float32) >>> a[0, :] = 1.0 >>> a[1, :] = 0.1 >>> np.mean(a) 0.54999924
Computing the mean in float64 is more accurate:
>>> np.mean(a, dtype=np.float64) 0.55000000074505806
set_params(**params)
[source]
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter>
so that it’s possible to update each component of a nested object.
Returns: 


transform(X)
[source]
Transform a new matrix using the built clustering
Parameters: 


Returns: 

sklearn.cluster.FeatureAgglomeration
© 2007–2018 The scikitlearn developers
Licensed under the 3clause BSD License.
http://scikitlearn.org/stable/modules/generated/sklearn.cluster.FeatureAgglomeration.html