reduce.py
import goldener.reduce
Dimensionality reduction of vectors.
The reduction tools reduce the dimension of 2D vectors, for instance to speed up the clustering or the selection on high dimensional embeddings:
GoldReductionToolis the abstract interface of all reduction tools.GoldReductionToolWithFitis the interface for the reduction methods requiring to be fitted on data.GoldSKLearnReductionToolwraps UMAP and scikit-learn methods (PCA, TSNE, GaussianRandomProjection).GoldTorchModuleReductionTooluses any PyTorch module to reduce the vectors.
Reduce the dimensionality of 2D vectors.
Base class for all dimensionality reduction tools.
Reduce the dimensionality of 2D vectors from fittable reduction methods.
Base class for dimensionality reduction tools that require fitting.
Fit the dimensionality reduction tool to the data.
Arguments:
- x: Already vectorized 2D input tensor of shape (num_vectors, feature_dim) to fit the model on.
Fit the dimensionality reduction tool to the 2D vectors and transform it.
Arguments:
- x: Already vectorized 2D input tensor of shape (num_vectors, feature_dim) to fit and transform.
Returns:
Transformed tensor with reduced dimensionality.
Inherited Members
Dimensionality reduction of 2D vectors with a torch Module.
Attributes:
- reducer: The torch Module to use for dimensionality reduction.
Dimensionality reduction of 2D vectors using UMAP, PCA, TSNE, or GaussianRandomProjection.
Attributes:
- _reducer: An instance of UMAP, PCA, TSNE, or GaussianRandomProjection.
Initialize the GoldSKLearnReductionTool.
Arguments:
- reducer: An instance of UMAP, PCA, TSNE, or GaussianRandomProjection for dimensionality reduction.
Fit the dimensionality reduction model to the 2D vectors.
Arguments:
- x: Already vectorized 2D input tensor of shape (num_vectors, feature_dim) to fit the model on.
Raises:
- ValueError: If input is not a 2D tensor.
Fit the dimensionality reduction model to the 2D vectors and transform it.
Arguments:
- x: Already vectorized 2D input tensor of shape (num_vectors, feature_dim) to fit and transform.
Returns:
Transformed tensor with reduced dimensionality.
Raises:
- ValueError: If input is not a 2D tensor.
Transform the 2D vectors using the fitted dimensionality reduction model.
Arguments:
- x: Already vectorized 2D input tensor of shape (num_vectors, feature_dim) to transform.
Returns:
Transformed tensor with reduced dimensionality.
Raises:
- ValueError: If input is not a 2D tensor.