evomap.mapping
==============

.. py:module:: evomap.mapping


Submodules
----------

.. toctree::
   :maxdepth: 1

   /autoapi/evomap/mapping/_cmds/index
   /autoapi/evomap/mapping/_mds/index
   /autoapi/evomap/mapping/_optim/index
   /autoapi/evomap/mapping/_regression/index
   /autoapi/evomap/mapping/_sammon/index
   /autoapi/evomap/mapping/_tsne/index
   /autoapi/evomap/mapping/evomap/index


Classes
-------

.. autoapisummary::

   evomap.mapping.CMDS
   evomap.mapping.EvoMDS
   evomap.mapping.EvoSammon
   evomap.mapping.EvoTSNE
   evomap.mapping.Sammon
   evomap.mapping.TSNE
   evomap.mapping.MDS


Package Contents
----------------

.. py:class:: CMDS(n_dims=2)

   .. py:attribute:: n_dims
      :value: 2



   .. py:method:: __str__()

      Create a string representation of the CMDS instance.



   .. py:method:: _cmdscale(D, n_dims, eps=1e-10)
      :staticmethod:


      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.

      :param D: Symmetric distance matrix to be scaled.
      :type D: np.array of shape (n, n)
      :param n_dims: Number of dimensions to which the data should be reduced.
      :type n_dims: int
      :param eps: Tolerance for numerical precision in rounding the resulting coordinates.
      :type eps: float, optional, default=1e-16

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



   .. py:method:: fit(X)

      Fit the CMDS model to the provided distance matrix.

      :param X: Symmetric distance matrix to be scaled.
      :type X: np.array of shape (n, n)

      :returns: **self** -- Returns the instance itself with the configuration matrix `Y_` stored as an attribute.
      :rtype: object



   .. py:method:: fit_transform(X)

      Fit the CMDS model to the distance matrix and return the transformed coordinates.

      :param X: Symmetric distance matrix to be scaled.
      :type X: np.array of shape (n, n)

      :returns: The transformed coordinates (configuration matrix) in the reduced dimensional space.
      :rtype: np.array of shape (n, n_dims)



.. py:class:: 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)

   Bases: :py:obj:`evomap.mapping.evomap._core.EvoMap`


   EvoMap Interface. Implements default functions shared by all
   implementation in its child classes.


   .. py:attribute:: n_dims
      :value: 2



   .. py:attribute:: n_iter
      :value: 2000



   .. py:attribute:: n_iter_check
      :value: 50



   .. py:attribute:: init
      :value: None



   .. py:attribute:: verbose
      :value: 0



   .. py:attribute:: mds_type
      :value: 'absolute'



   .. py:attribute:: input_type
      :value: 'distance'



   .. py:attribute:: max_halves
      :value: 5



   .. py:attribute:: tol
      :value: 0.001



   .. py:attribute:: n_inits
      :value: 1



   .. py:attribute:: step_size
      :value: 1



   .. py:attribute:: max_tries
      :value: 5



   .. py:attribute:: method_str
      :value: 'EvoMDS'



   .. py:method:: __str__()

      Return a string representation of the EvoMDS instance with key parameters and user-modified values.



   .. py:method:: fit(Xs, inclusions=None)

      Fit the EvoMDS model to the input data over multiple periods.

      :param Xs: 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`.
      :type Xs: list of np.ndarray
      :param inclusions: Binary array indicating which points are included in the calculation,
                         by default None.
      :type inclusions: np.ndarray, optional

      :returns: **self** -- Returns the instance of the EvoMDS class with the configuration matrix
                `Ys_` stored as an attribute.
      :rtype: object



   .. py:method:: fit_transform(Xs, inclusions=None)

      Fit the EvoMDS model and return the transformed coordinates.

      :param Xs: 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`.
      :type Xs: list of np.ndarray
      :param inclusions: Binary array indicating which points are included in the calculation,
                         by default None.
      :type inclusions: np.ndarray, optional

      :returns: The transformed coordinates for each period, stored as a list of matrices.
      :rtype: list of np.ndarray

      :raises ValueError: If the `input_type` is not 'distance' or 'vector'.



.. py:class:: 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)

   Bases: :py:obj:`evomap.mapping.evomap._core.EvoMap`


   EvoMap Interface. Implements default functions shared by all
   implementation in its child classes.


   .. py:attribute:: n_dims
      :value: 2



   .. py:attribute:: n_iter
      :value: 2000



   .. py:attribute:: n_iter_check
      :value: 50



   .. py:attribute:: init
      :value: None



   .. py:attribute:: verbose
      :value: 0



   .. py:attribute:: input_type
      :value: 'distance'



   .. py:attribute:: max_halves
      :value: 5



   .. py:attribute:: tol
      :value: 0.001



   .. py:attribute:: n_inits
      :value: 1



   .. py:attribute:: step_size
      :value: 1



   .. py:attribute:: max_tries
      :value: 5



   .. py:attribute:: method_str
      :value: 'EvoSammon'



   .. py:method:: __str__()

      Return a string representation of the EvoSammon instance with alpha, p, and user-modified parameters.



   .. py:method:: fit(Xs)

      Fit EvoSammon to the input data over multiple periods.

      :param Xs: 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`.
      :type Xs: list of np.ndarray

      :returns: **self** -- Returns the instance of the EvoSammon class with the configuration matrix
                `Ys_` stored as an attribute.
      :rtype: object



   .. py:method:: fit_transform(Xs, inclusions=None)

      Fit the EvoSammon model and return the transformed coordinates.

      :param Xs: 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`.
      :type Xs: list of np.ndarray
      :param inclusions: Binary array indicating which points are included in the calculation,
                         by default None.
      :type inclusions: np.ndarray, optional

      :returns: The transformed coordinates for each period, stored as a list of matrices.
      :rtype: list of np.ndarray

      :raises ValueError: If the `input_type` is not 'distance' or 'vector'.



.. py:class:: 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)

   Bases: :py:obj:`evomap.mapping.evomap._core.EvoMap`


   EvoMap Interface. Implements default functions shared by all
   implementation in its child classes.


   .. py:attribute:: n_dims
      :value: 2



   .. py:attribute:: perplexity
      :value: 15



   .. py:attribute:: stop_lying_iter
      :value: 250



   .. py:attribute:: early_exaggeration
      :value: 4



   .. py:attribute:: eta
      :value: 'auto'



   .. py:attribute:: initial_momentum
      :value: 0.5



   .. py:attribute:: final_momentum
      :value: 0.8



   .. py:attribute:: n_iter
      :value: 2000



   .. py:attribute:: n_iter_check
      :value: 50



   .. py:attribute:: init
      :value: None



   .. py:attribute:: verbose
      :value: 0



   .. py:attribute:: input_type
      :value: 'distance'



   .. py:attribute:: max_halves
      :value: 5



   .. py:attribute:: tol
      :value: 0.001



   .. py:attribute:: n_inits
      :value: 1



   .. py:attribute:: max_tries
      :value: 5



   .. py:attribute:: method_str
      :value: 'EvoTSNE'



   .. py:method:: __str__()

      Return a string representation of the EvoTSNE instance with alpha, p, perplexity, and user-modified parameters.



   .. py:method:: fit(Xs)

      Fit EvoTSNE to the input data over multiple periods.

      :param Xs: 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`.
      :type Xs: list of np.ndarray

      :returns: **self** -- Returns the instance of the EvoTSNE class with the configuration matrix
                `Ys_` stored as an attribute.
      :rtype: object



   .. py:method:: fit_transform(Xs, inclusions=None)

      Fit EvoTSNE and return the transformed coordinates.

      :param Xs: 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`.
      :type Xs: list of np.ndarray
      :param inclusions: Binary array indicating which points are included in the calculation,
                         by default None.
      :type inclusions: np.ndarray, optional

      :returns: The transformed coordinates for each period, stored as a list of matrices.
      :rtype: list of np.ndarray

      :raises ValueError: If the `input_type` is not 'distance' or 'vector'.



.. py:class:: 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)

   .. py:attribute:: n_dims
      :value: 2



   .. py:attribute:: n_iter
      :value: 2000



   .. py:attribute:: n_iter_check
      :value: 50



   .. py:attribute:: init
      :value: None



   .. py:attribute:: verbose
      :value: 0



   .. py:attribute:: input_type
      :value: 'distance'



   .. py:attribute:: max_halves
      :value: 5



   .. py:attribute:: tol
      :value: 0.001



   .. py:attribute:: n_inits
      :value: 1



   .. py:attribute:: step_size
      :value: 1



   .. py:attribute:: method_str
      :value: 'SAMMON'



   .. py:method:: __str__()

      Return a string representation of the Sammon instance with input_type and user-modified parameters.



   .. py:method:: fit(X)

      Fit the Sammon model to the input data.

      :param X: 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.
      :type X: np.array of shape (n_samples, n_features) or (n_samples, n_samples)

      :returns: **self** -- Returns the instance of the Sammon class with the configuration matrix
                `Y_` stored as an attribute.
      :rtype: object



   .. py:method:: fit_transform(X)

      Fit the Sammon mapping model and return the transformed coordinates.

      :param X: 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.
      :type X: np.array of shape (n_samples, n_features) or (n_samples, n_samples)

      :returns: The transformed coordinates of the samples in the reduced-dimensional space.
      :rtype: np.array of shape (n_samples, n_dims)

      :raises ValueError: If the `input_type` is not 'distance' or 'vector'.



.. py:class:: 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)

   .. py:attribute:: n_dims
      :value: 2



   .. py:attribute:: perplexity
      :value: 15



   .. py:attribute:: n_iter
      :value: 2000



   .. py:attribute:: stop_lying_iter
      :value: 250



   .. py:attribute:: early_exaggeration
      :value: 4



   .. py:attribute:: initial_momentum
      :value: 0.5



   .. py:attribute:: final_momentum
      :value: 0.8



   .. py:attribute:: eta
      :value: 'auto'



   .. py:attribute:: n_iter_check
      :value: 50



   .. py:attribute:: init
      :value: None



   .. py:attribute:: verbose
      :value: 0



   .. py:attribute:: input_type
      :value: 'distance'



   .. py:attribute:: max_halves
      :value: 5



   .. py:attribute:: tol
      :value: 0.001



   .. py:attribute:: n_inits
      :value: 1



   .. py:attribute:: step_size
      :value: 1



   .. py:attribute:: method_str
      :value: 'TSNE'



   .. py:method:: __str__()

      Return a string representation of the TSNE instance with key parameters and user-modified values.



   .. py:method:: fit(X)

      Fit the TSNE model to the input data, without returning the transformed coordinates.

      :param X: 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.
      :type X: np.array of shape (n_samples, n_features) or (n_samples, n_samples)

      :returns: **self** -- Returns the instance of the TSNE class with the configuration matrix
                `Y_` stored as an attribute.
      :rtype: object



   .. py:method:: fit_transform(X)

      Fit the TSNE model and return the transformed coordinates.

      :param X: 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.
      :type X: np.array of shape (n_samples, n_features) or (n_samples, n_samples)

      :returns: The transformed coordinates in the reduced-dimensional space.
      :rtype: np.array of shape (n_samples, n_dims)

      :raises ValueError: If the `input_type` is not 'distance' or 'vector'.



.. py:class:: 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)

   .. py:attribute:: n_dims
      :value: 2



   .. py:attribute:: mds_type
      :value: None



   .. py:attribute:: n_iter
      :value: 2000



   .. py:attribute:: n_iter_check
      :value: 50



   .. py:attribute:: init
      :value: None



   .. py:attribute:: verbose
      :value: 0



   .. py:attribute:: input_type
      :value: 'distance'



   .. py:attribute:: max_halves
      :value: 5



   .. py:attribute:: tol
      :value: 0.001



   .. py:attribute:: n_inits
      :value: 1



   .. py:attribute:: step_size
      :value: 1



   .. py:attribute:: method_str
      :value: 'MDS'



   .. py:method:: __str__()

      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.
      :rtype: str



   .. py:method:: fit(X)

      Fit the MDS model to the input data, without returning the
      transformed positions.

      :param X: 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.
      :type X: np.array of shape (n_samples, n_features) or (n_samples, n_samples)

      :returns: **self** -- The instance of the MDS class, after fitting the model to the input data.
      :rtype: object



   .. py:method:: fit_transform(X)

      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.

      :param X: 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.
      :type X: np.array of shape (n_samples, n_features) or (n_samples, n_samples)

      :returns: The transformed positions in the lower-dimensional space.
      :rtype: np.array of shape (n_samples, n_dims)

      :raises ValueError: If `input_type` is neither 'distance' nor 'vector', a ValueError is raised.



