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

.. py:module:: evomap.mapping._cmds

.. autoapi-nested-parse::

   Classic (SVD-based) Multidimensional Scaling, as proposed in:

   Torgerson, W.S. Multidimensional scaling: I. Theory and method. Psychometrika 17, 401–419 (1952).

   Thanks to Francis Song, from whom this implementation has borrowed. Source: http://www.nervouscomputer.com/hfs/cmdscale-in-python/



Classes
-------

.. autoapisummary::

   evomap.mapping._cmds.CMDS


Module 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)



