evomap.mapping#
Subpackages#
Submodules#
Classes#
Package Contents#
- class evomap.mapping.CMDS(n_dims=2)[source]#
- n_dims = 2#
- static _cmdscale(D, n_dims, eps=1e-16)[source]#
Perform classical multidimensional scaling (CMDS) on the input distance matrix.
CMDS reduces the dimensionality of a distance matrix while preserving the pairwise distances as well as possible using eigenvalue decomposition.
- Parameters:
D (np.array of shape (n, n)) – Symmetric distance matrix to be scaled.
n_dims (int) – Number of dimensions to which the data should be reduced.
eps (float, optional, default=1e-16) – Tolerance for numerical precision in rounding the resulting coordinates.
- Returns:
Y (np.array of shape (n, n_dims)) – Configuration matrix with the reduced dimensionality representation of the points.
e (np.array of shape (n,)) – The eigenvalues corresponding to the dimensions.
- Raises:
ValueError – If the input matrix D is not square or symmetric.
- fit(X)[source]#
Fit the CMDS model to the provided distance matrix.
- Parameters:
X (np.array of shape (n, n)) – Symmetric distance matrix to be scaled.
- Returns:
self – Returns the instance itself with the configuration matrix Y_ stored as an attribute.
- Return type:
object
- fit_transform(X)[source]#
Fit the CMDS model to the distance matrix and return the transformed coordinates.
- Parameters:
X (np.array of shape (n, n)) – Symmetric distance matrix to be scaled.
- Returns:
The transformed coordinates (configuration matrix) in the reduced dimensional space.
- Return type:
np.array of shape (n, n_dims)
- class evomap.mapping.EvoMDS(alpha=0, p=1, n_dims=2, n_iter=2000, n_iter_check=50, init=None, mds_type='absolute', verbose=0, input_type='distance', max_halves=5, tol=0.001, n_inits=1, step_size=1, max_tries=5)[source]#
Bases:
evomap.mapping.evomap._core.EvoMapEvoMap Interface. Implements default functions shared by all implementation in its child classes.
- n_dims#
- n_iter#
- n_iter_check#
- init#
- verbose#
- mds_type#
- input_type#
- max_halves#
- tol#
- n_inits#
- step_size#
- max_tries#
- method_str = 'EvoMDS'#
- __str__()[source]#
Return a string representation of the EvoMDS instance with key parameters and user-modified values.
- fit(Xs, inclusions=None)[source]#
Fit the EvoMDS model to the input data over multiple periods.
- Parameters:
Xs (list of np.ndarray) – A list of input matrices, where each matrix corresponds to one period. The input matrices can either be feature vectors or distance matrices, depending on the input_type.
inclusions (np.ndarray, optional) – Binary array indicating which points are included in the calculation, by default None.
- Returns:
self – Returns the instance of the EvoMDS class with the configuration matrix Ys_ stored as an attribute.
- Return type:
object
- fit_transform(Xs, inclusions=None)[source]#
Fit the EvoMDS model and return the transformed coordinates.
- Parameters:
Xs (list of np.ndarray) – A list of input matrices, where each matrix corresponds to one period. The input matrices can either be feature vectors or distance matrices, depending on the input_type.
inclusions (np.ndarray, optional) – Binary array indicating which points are included in the calculation, by default None.
- Returns:
The transformed coordinates for each period, stored as a list of matrices.
- Return type:
list of np.ndarray
- Raises:
ValueError – If the input_type is not ‘distance’ or ‘vector’.
- class evomap.mapping.EvoSammon(alpha=0, p=1, n_dims=2, n_iter=2000, n_iter_check=50, init=None, verbose=0, input_type='distance', max_halves=5, tol=0.001, n_inits=1, step_size=1, max_tries=5)[source]#
Bases:
evomap.mapping.evomap._core.EvoMapEvoMap Interface. Implements default functions shared by all implementation in its child classes.
- n_dims#
- n_iter#
- n_iter_check#
- init#
- verbose#
- input_type#
- max_halves#
- tol#
- n_inits#
- step_size#
- max_tries#
- method_str = 'EvoSammon'#
- __str__()[source]#
Return a string representation of the EvoSammon instance with alpha, p, and user-modified parameters.
- fit(Xs)[source]#
Fit EvoSammon to the input data over multiple periods.
- Parameters:
Xs (list of np.ndarray) – A list of input matrices, where each matrix corresponds to one period. The input matrices can either be feature vectors or distance matrices, depending on the input_type.
- Returns:
self – Returns the instance of the EvoSammon class with the configuration matrix Ys_ stored as an attribute.
- Return type:
object
- fit_transform(Xs, inclusions=None)[source]#
Fit the EvoSammon model and return the transformed coordinates.
- Parameters:
Xs (list of np.ndarray) – A list of input matrices, where each matrix corresponds to one period. The input matrices can either be feature vectors or distance matrices, depending on the input_type.
inclusions (np.ndarray, optional) – Binary array indicating which points are included in the calculation, by default None.
- Returns:
The transformed coordinates for each period, stored as a list of matrices.
- Return type:
list of np.ndarray
- Raises:
ValueError – If the input_type is not ‘distance’ or ‘vector’.
- class evomap.mapping.EvoTSNE(alpha=0, p=1, n_dims=2, perplexity=15, stop_lying_iter=250, early_exaggeration=4, eta='auto', initial_momentum=0.5, final_momentum=0.8, n_iter=2000, n_iter_check=50, init=None, verbose=0, input_type='distance', max_halves=5, tol=0.001, n_inits=1, max_tries=5)[source]#
Bases:
evomap.mapping.evomap._core.EvoMapEvoMap Interface. Implements default functions shared by all implementation in its child classes.
- n_dims#
- perplexity#
- stop_lying_iter#
- early_exaggeration#
- eta#
- initial_momentum#
- final_momentum#
- n_iter#
- n_iter_check#
- init#
- verbose#
- input_type#
- max_halves#
- tol#
- n_inits#
- max_tries#
- method_str = 'EvoTSNE'#
- __str__()[source]#
Return a string representation of the EvoTSNE instance with alpha, p, perplexity, and user-modified parameters.
- fit(Xs)[source]#
Fit EvoTSNE to the input data over multiple periods.
- Parameters:
Xs (list of np.ndarray) – A list of input matrices, where each matrix corresponds to one period. The input matrices can either be feature vectors or distance matrices, depending on the input_type.
- Returns:
self – Returns the instance of the EvoTSNE class with the configuration matrix Ys_ stored as an attribute.
- Return type:
object
- fit_transform(Xs, inclusions=None)[source]#
Fit EvoTSNE and return the transformed coordinates.
- Parameters:
Xs (list of np.ndarray) – A list of input matrices, where each matrix corresponds to one period. The input matrices can either be feature vectors or distance matrices, depending on the input_type.
inclusions (np.ndarray, optional) – Binary array indicating which points are included in the calculation, by default None.
- Returns:
The transformed coordinates for each period, stored as a list of matrices.
- Return type:
list of np.ndarray
- Raises:
ValueError – If the input_type is not ‘distance’ or ‘vector’.
- class evomap.mapping.Sammon(n_dims=2, n_iter=2000, n_iter_check=50, init=None, verbose=0, input_type='distance', max_halves=5, tol=0.001, n_inits=1, step_size=1)[source]#
- n_dims#
- n_iter#
- n_iter_check#
- init#
- verbose#
- input_type#
- max_halves#
- tol#
- n_inits#
- step_size#
- method_str = 'SAMMON'#
- __str__()[source]#
Return a string representation of the Sammon instance with input_type and user-modified parameters.
- fit(X)[source]#
Fit the Sammon model to the input data.
- Parameters:
X (np.array of shape (n_samples, n_features) or (n_samples, n_samples)) – The input data. If input_type is ‘vector’, X should be the feature vectors of the samples. If input_type is ‘distance’, X should be the pairwise distance matrix.
- Returns:
self – Returns the instance of the Sammon class with the configuration matrix Y_ stored as an attribute.
- Return type:
object
- fit_transform(X)[source]#
Fit the Sammon mapping model and return the transformed coordinates.
- Parameters:
X (np.array of shape (n_samples, n_features) or (n_samples, n_samples)) – The input data. If input_type is ‘vector’, X should be the feature vectors of the samples. If input_type is ‘distance’, X should be the pairwise distance matrix.
- Returns:
The transformed coordinates of the samples in the reduced-dimensional space.
- Return type:
np.array of shape (n_samples, n_dims)
- Raises:
ValueError – If the input_type is not ‘distance’ or ‘vector’.
- class evomap.mapping.TSNE(n_dims=2, perplexity=15, n_iter=2000, stop_lying_iter=250, early_exaggeration=4, initial_momentum=0.5, final_momentum=0.8, eta='auto', n_iter_check=50, init=None, verbose=0, input_type='distance', max_halves=5, tol=0.001, n_inits=1, step_size=1)[source]#
- n_dims#
- perplexity#
- n_iter#
- stop_lying_iter#
- early_exaggeration#
- initial_momentum#
- final_momentum#
- eta#
- n_iter_check#
- init#
- verbose#
- input_type#
- max_halves#
- tol#
- n_inits#
- step_size#
- method_str = 'TSNE'#
- __str__()[source]#
Return a string representation of the TSNE instance with key parameters and user-modified values.
- fit(X)[source]#
Fit the TSNE model to the input data, without returning the transformed coordinates.
- Parameters:
X (np.array of shape (n_samples, n_features) or (n_samples, n_samples)) – The input data. If input_type is ‘vector’, X should be the feature vectors of the samples. If input_type is ‘distance’, X should be the pairwise distance matrix.
- Returns:
self – Returns the instance of the TSNE class with the configuration matrix Y_ stored as an attribute.
- Return type:
object
- fit_transform(X)[source]#
Fit the TSNE model and return the transformed coordinates.
- Parameters:
X (np.array of shape (n_samples, n_features) or (n_samples, n_samples)) – The input data. If input_type is ‘vector’, X should be the feature vectors of the samples. If input_type is ‘distance’, X should be the pairwise distance matrix.
- Returns:
The transformed coordinates in the reduced-dimensional space.
- Return type:
np.array of shape (n_samples, n_dims)
- Raises:
ValueError – If the input_type is not ‘distance’ or ‘vector’.
- class evomap.mapping.MDS(n_dims=2, mds_type=None, n_iter=2000, n_iter_check=50, init=None, verbose=0, input_type='distance', max_halves=5, tol=0.001, n_inits=1, step_size=1)[source]#
- n_dims#
- mds_type#
- n_iter#
- n_iter_check#
- init#
- verbose#
- input_type#
- max_halves#
- tol#
- n_inits#
- step_size#
- method_str = 'MDS'#
- __str__()[source]#
Create a string representation of the MDS instance. Displays the key attributes and all parameters modified by the user.
- Returns:
A summary of the key attributes of this MDS object, including modified parameters.
- Return type:
str
- fit(X)[source]#
Fit the MDS model to the input data, without returning the transformed positions.
- Parameters:
X (np.array of shape (n_samples, n_features) or (n_samples, n_samples)) – The input data. If input_type is ‘vector’, X should be the feature vectors of the samples. If input_type is ‘distance’, X should be a pairwise distance matrix.
- Returns:
self – The instance of the MDS class, after fitting the model to the input data.
- Return type:
object
- fit_transform(X)[source]#
Fit the MDS model to the input data and return transformed positions.
Dependning on ‘input_type’, the input data is either interpreted as a distance matrix or feature vectors. The method uses gradient descent to optimize the lower-dimensional positions such that a Stress function, measuring the discrepancy between the input distances and resulting configuration, is minimized.
- Parameters:
X (np.array of shape (n_samples, n_features) or (n_samples, n_samples)) – The input data. If input_type is ‘vector’, X should be the feature vectors of the samples. If input_type is ‘distance’, X should be a pairwise distance matrix.
- Returns:
The transformed positions in the lower-dimensional space.
- Return type:
np.array of shape (n_samples, n_dims)
- Raises:
ValueError – If input_type is neither ‘distance’ nor ‘vector’, a ValueError is raised.