Example #1
0
    def __init__(self, scaling=True, reflection=True, reduction=True,
                 oblique=False, oblique_rcond=-1, **kwargs):
        """Initialize the ProcrusteanMapper

        :Parameters:
          scaling: bool
            Scale data for the transformation (no longer rigid body
            transformation)
          reflection: bool
            Allow for the data to be reflected (so it might not be a rotation).
            Effective only for non-oblique transformations
          reduction: bool
            If true, it is allowed to map into lower-dimensional
            space. Forward transformation might be suboptimal then and reverse
            transformation might not recover all original variance
          oblique: bool
            Either to allow non-orthogonal transformation -- might heavily overfit
            the data if there is less samples than dimensions. Use `oblique_rcond`.
          oblique_rcond: float
            Cutoff for 'small' singular values to regularize the inverse. See
            :class:`~numpy.linalg.lstsq` for more information.
        """
        ProjectionMapper.__init__(self, **kwargs)

        self._scaling = scaling
        """Either to determine the scaling factor"""

        self._reduction = reduction
        self._reflection = reflection
        self._oblique = oblique
        self._oblique_rcond = oblique_rcond
        self._scale = None
        """Estimated scale"""
Example #2
0
 def selectOut(self, outIds):
     """Choose a subset of SVD components (and remove all others)."""
     # handle ElementSelector operating on SV (base class has no idea about)
     # XXX think about more generic interface, where some 'measure' is assigned
     # per each projection dimension, like in _sv in case of SVD.
     # May be selector could be parametrized with an instance + attribute as literal
     # so later on it could extract necessary values?
     if isinstance(self._selector, ElementSelector):
         ProjectionMapper.selectOut(self, self._selector(self._sv))
     else:
         ProjectionMapper.selectOut(self, outIds)
Example #3
0
    def __init__(self,
                 baselinelabels=None,
                 **kwargs):
        """Initialize ZScoreMapper

        :Parameters:
          baselinelabels : None or list of int or string
            Used to compute mean and variance
            TODO: not in effect now and need to be adherent to all
            `ProjectionMapper`s
        """

        ProjectionMapper.__init__(self, **kwargs)
        if baselinelabels is not None:
            raise NotImplementedError, "Support for baseline labels " \
                  "is not yet implemented in ZScoreMapper"
        self.baselinelabels = baselinelabels
Example #4
0
 def __repr__(self):
     s = ProjectionMapper.__repr__(self).rstrip(' )')
     if not s[-1] == '(': s += ', '
     s += "scaling=%d, reflection=%d, reduction=%d, " \
          "oblique=%s, oblique_rcond=%g)" % \
          (self._scaling, self._reflection, self._reduction,
           self._oblique, self._oblique_rcond)
     return s
Example #5
0
    def __init__(self, **kwargs):
        """Initialize the SVDMapper

        :Parameters:
          **kwargs:
            All keyword arguments are passed to the ProjectionMapper
            constructor.

            Note, that for the 'selector' argument this class also supports
            passing a `ElementSelector` instance, which will be used to
            determine the to be selected features, based on the singular
            values of each component.
        """
        ProjectionMapper.__init__(self, **kwargs)

        self._sv = None
        """Singular values of the training matrix."""
Example #6
0
    def __init__(self, transpose=False, **kwargs):
        ProjectionMapper.__init__(self, **kwargs)

        self._var = None
Example #7
0
    def __init__(self, algorithm='cubica', transpose=False, **kwargs):
        ProjectionMapper.__init__(self, **kwargs)

        self._algorithm = algorithm
        self._transpose = transpose