orthrus.decomposition namespace

Submodules

orthrus.decomposition.general module

This module contains methods related to general data decompositions outside of the standard sklearn library

class orthrus.decomposition.general.OrthTransform(subspace, shift, transformer, transformer_args={})

Bases: sklearn.base.BaseEstimator

This class takes a subspace :py:math:`S` (OrthTransform.subspace) and affine shift :py:math:`x_0` (OrthTransform.shift) and resolves data :py:math:`X`, with :py:math:`m` rows (samples) and :py:math:`n` columns (features), onto :py:math:`S` and its orthogonal complement :py:math:`S^{\perp}`. The data resolved onto :py:math:`S^{\perp}` is then transformed by a function :py:math:`T`, represented by the fit_transform method of OrthTransform.transformer,to reduce the dimension of the orthogonal components.

Parameters
  • subspace (ndarray of shape (n_features, subspace_dimension)) – The matrix whose columns span the subspace in consideration.

  • normalize_1d_subspace (bool) – If False and the subspace is one-dimensional, the projection of the data onto the subspace will be scaled by the length of the vector respresenting the subspace. This is useful for prediction models such as SVM where the magnitude of the normal vector is included in the model. If True then the the vector representing the subspace will be made into a unit vector before multiplying the data. The default is False.

  • shift (1-d array with n_features components) – The point in space to affinely shift the data by— we subtract the point.

  • transformer (class instance) – The transformation object to transform the orthogonal complement to the subspace— must have a fit_transform method.

  • transformer_args (dict) – The dictionary of arguments to be passed to the transformers fit method. The default is an empty dictionary.

coordinates

The embedding produced by OrthTransform where n_components is the number of components given in OrthTransform.subspace combined with the number of components given in OrthTransform.transformer.

Type

ndarray of shape (n_samples, n_components)

fit(X, y=None)

Computes the transformed coordinates of the orthogonal complement to the shifted data, and post-concatenates this to the coordinates of the shifted data projected into the subspace.

Parameters
  • X (array-like of shape (n_samples, n_samples)) – An array representing the data.

  • y (Ignored) –

Returns

The fit OrthTransform instance.

Return type

OrthTransform

fit_transform(X, y=None)

Fits the orthogonal transform model to the data via OrthTransform.fit(), returns the embedding stored in OrthTransform.coordinates_.

Parameters
  • X (array-like of shape (n_samples, n_samples)) – An array representing the data.

  • y (Ignored) –

Returns

The embedding produced by OrthTransform where n_components

is the number of components given in OrthTransform.subspace combined with the number of components given in OrthTransform.transformer

Return type

ndarray of shape (n_samples, n_components)

orthrus.decomposition.general.align_embedding(prev_embedding: numpy.ndarray)

This class decorator with parameters attempts to align embedding coordinates to a previous embeddings coordinates by editing the fit_transform method of the class responsible for the embedding. This is useful for continuity in visualizations over time.

Parameters

prev_embedding – Previous embedding to align to.

Returns

Method which transforms classes fit_transform method to align to the previous embedding.

Return type

method