feature_extraction module

class divik.feature_extraction.LocallyAdjustedRbfSpectralEmbedding(distance: str = 'euclidean', n_components=2, random_state=None, eigen_solver: str = None, n_neighbors: int = None, n_jobs: int = 1)[source]

Spectral embedding for non-linear dimensionality reduction.

Forms an affinity matrix given by the specified function and applies spectral decomposition to the corresponding graph laplacian. The resulting transformation is given by the value of the eigenvectors for each data point.

Note : Laplacian Eigenmaps is the actual algorithm implemented here.

Parameters:
distance : {‘braycurtis’, ‘canberra’, ‘chebyshev’, ‘cityblock’,
‘correlation’, ‘cosine’, ‘dice’, ‘euclidean’, ‘hamming’, ‘jaccard’,
‘kulsinski’, ‘mahalanobis’, ‘atching’, ‘minkowski’, ‘rogerstanimoto’,
‘russellrao’, ‘sokalmichener’, ‘sokalsneath’, ‘sqeuclidean’, ‘yule’}

Distance measure, defaults to ‘euclidean’. These are the distances supported by scipy package.

n_components : integer, default: 2

The dimension of the projected subspace.

random_state : int, RandomState instance or None, optional, default: None

A pseudo random number generator used for the initialization of the lobpcg eigenvectors. If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random. Used when solver == ‘amg’.

eigen_solver : {None, ‘arpack’, ‘lobpcg’, or ‘amg’}

The eigenvalue decomposition strategy to use. AMG requires pyamg to be installed. It can be faster on very large, sparse problems, but may also lead to instabilities.

n_neighbors : int, default

Number of nearest neighbors for nearest_neighbors graph building.

n_jobs : int, optional (default = 1)

The number of parallel jobs to run. If -1, then the number of jobs is set to the number of CPU cores.

References

Attributes:
embedding_ : array, shape = (n_samples, n_components)

Spectral embedding of the training matrix.

Methods

fit(self, X[, y]) Fit the model from data in X.
fit_transform(self, X[, y]) Fit the model from data in X and transform X.
get_params(self[, deep]) Get parameters for this estimator.
save(self, destination) Save embedding to a directory
set_params(self, \*\*params) Set the parameters of this estimator.
fit(self, X, y=None)[source]

Fit the model from data in X.

Parameters:
X : array-like, shape (n_samples, n_features)

Training vector, where n_samples is the number of samples and n_features is the number of features.

Y: Ignored.
Returns:
self : object

Returns the instance itself.

fit_transform(self, X, y=None)[source]

Fit the model from data in X and transform X.

Parameters:
X : array-like, shape (n_samples, n_features)

Training vector, where n_samples is the number of samples and n_features is the number of features.

Y: Ignored.
Returns:
X_new : array-like, shape (n_samples, n_components)
get_params(self, deep=True)

Get parameters for this estimator.

Parameters:
deep : boolean, optional

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
params : mapping of string to any

Parameter names mapped to their values.

save(self, destination:str)[source]

Save embedding to a directory

Parameters:
destination : str

Directory to save the embedding.

set_params(self, **params)

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:
self