Пример #1
0
 def __init__(self, exog, model_gen, res='params', add_constant=True,
              **kwargs):
     """
     Parameters
     ----------
     exog : array-like
         Column ordered (observations in rows) design matrix.
     model_gen : callable
         Callable that returns a StatsModels model when called like
         ``model_gen(endog, exog)``.
     res : {'params', 'tvalues', ...} or 1d array or 2d array or callable
       Variable of interest that should be reported as feature-wise
       measure. If a str, the corresponding attribute of the model fit result
       class is returned (e.g. 'tvalues'). If a 1d-array, it is passed
       to the fit result class' ``t_test()`` function as a t-contrast vector.
       If a 2d-array, it is passed to the ``f_test()`` function as a
       constrast matrix. If both latter cases a number of common test
       statistics are return in the rows of the result dataset. A description
       is available in the 'descr' sample attribute. Any other datatype
       passed to this argument will be treated as a callable, the model
       fit result is passed to it, and its return value(s) is aggregated
       in the result dataset.
     add_constant : bool
         If True, a constant will be added to the design matrix that is
         passed to ``exog``.
     """
     FeaturewiseMeasure.__init__(self, **kwargs)
     self._exog = exog
     if add_constant:
         self._exog = sm.add_constant(exog)
     self._res = res
     if isinstance(res, np.ndarray) or isinstance(res, (list, tuple)):
         self._res = np.atleast_1d(res)
     self._model_gen = model_gen
Пример #2
0
 def __init__(self, exog, model_gen, res='params', add_constant=True,
              **kwargs):
     """
     Parameters
     ----------
     exog : array-like
       Column ordered (observations in rows) design matrix.
     model_gen : callable
       Callable that returns a StatsModels model when called like
       ``model_gen(endog, exog)``.
     res : {'params', 'tvalues', ...} or 1d array or 2d array or callable
       Variable of interest that should be reported as feature-wise
       measure. If a str, the corresponding attribute of the model fit result
       class is returned (e.g. 'tvalues'). If a 1d-array, it is passed
       to the fit result class' ``t_test()`` function as a t-contrast vector.
       If a 2d-array, it is passed to the ``f_test()`` function as a
       contrast matrix.  In both latter cases a number of common test
       statistics are returned in the rows of the result dataset. A description
       is available in the 'descr' sample attribute. Any other datatype
       passed to this argument will be treated as a callable, the model
       fit result is passed to it, and its return value(s) is aggregated
       in the result dataset.
     add_constant : bool, optional
       If True, a constant will be added to the design matrix that is
       passed to ``exog``.
     """
     FeaturewiseMeasure.__init__(self, **kwargs)
     self._exog = exog
     if add_constant:
         self._exog = sm.add_constant(exog)
     self._res = res
     if isinstance(res, np.ndarray) or isinstance(res, (list, tuple)):
         self._res = np.atleast_1d(res)
     self._model_gen = model_gen
Пример #3
0
    def __init__(self, design, voi='pe', **kwargs):
        """
        Parameters
        ----------
        design : array (nsamples x nregressors)
          GLM design matrix.
        voi : {'pe', 'zstat'}
          Variable of interest that should be reported as feature-wise
          measure. 'beta' are the parameter estimates and 'zstat' returns
          standardized parameter estimates.
        """
        FeaturewiseMeasure.__init__(self, **kwargs)
        # store the design matrix as a such (no copying if already array)
        self._design = np.asmatrix(design)

        # what should be computed ('variable of interest')
        if not voi in ['pe', 'zstat']:
            raise ValueError, \
                  "Unknown variable of interest '%s'" % str(voi)
        self._voi = voi

        # will store the precomputed Moore-Penrose pseudo-inverse of the
        # design matrix (lazy calculation)
        self._inv_design = None
        # also store the inverse of the inner product for beta variance
        # estimation
        self._inv_ip = None
Пример #4
0
    def __init__(self,
                 pvalue=False,
                 attr='targets',
                 corr_backend=None,
                 **kwargs):
        """Initialize

        Parameters
        ----------
        pvalue : bool
          Either to report p-value of pearsons correlation coefficient
          instead of pure correlation coefficient
        attr : str
          What attribut to correlate with
        corr_backend: None or 'builtin' or 'scipy' (default: None)
          Which function to use to compute correlations.
          None means 'scipy' if pvalue else 'builtin'. 
        """
        # init base classes first

        FeaturewiseMeasure.__init__(self, **kwargs)

        self.__pvalue = int(pvalue)
        self.__attr = attr
        self.__corr_backend = corr_backend
Пример #5
0
    def __init__(self, num_permutations=200, num_bootstraps=100, **kwargs):
        raise NotImplemented, 'PLS was not yet implemented fully'

        # init base classes first
        FeaturewiseMeasure.__init__(self, **kwargs)

        # save the args for the analysis
        self.num_permutations = num_permutations
        self.num_bootstraps = num_bootstraps
Пример #6
0
    def __init__(self, num_permutations=200, num_bootstraps=100, **kwargs):
        raise NotImplemented, 'PLS was not yet implemented fully'

        # init base classes first
        FeaturewiseMeasure.__init__(self, **kwargs)

        # save the args for the analysis
        self.num_permutations = num_permutations
        self.num_bootstraps = num_bootstraps
Пример #7
0
    def __init__(self, space='targets', **kwargs):
        """Initialize

        Parameters
        ----------
        space : str
          What samples attribute to use as targets (labels).
        """
        # init base classes first
        FeaturewiseMeasure.__init__(self, space=space, **kwargs)
Пример #8
0
    def __init__(self, space='targets', **kwargs):
        """Initialize

        Parameters
        ----------
        space : str
          What samples attribute to use as targets (labels).
        """
        # init base classes first
        FeaturewiseMeasure.__init__(self, space=space, **kwargs)
Пример #9
0
 def __init__(self, space='targets', **kwargs):
     """
     Parameters
     ----------
     space : str
       What samples attribute to use as targets (labels).
     """
     # set auto-train flag since we have nothing special to be done
     # so by default auto train
     kwargs['auto_train'] = kwargs.get('auto_train', True)
     FeaturewiseMeasure.__init__(self, space=space, **kwargs)
Пример #10
0
 def __init__(self, space='targets', **kwargs):
     """
     Parameters
     ----------
     space : str
       What samples attribute to use as targets (labels).
     """
     # set auto-train flag since we have nothing special to be done
     # so by default auto train
     kwargs['auto_train'] = kwargs.get('auto_train', True)
     FeaturewiseMeasure.__init__(self, space=space, **kwargs)
Пример #11
0
    def __init__(self, attr="targets", **kwargs):
        """Initialize

        Parameters
        ----------
        attr : str
          Attribute to correlate across chunks.
        """
        # init base classes first
        FeaturewiseMeasure.__init__(self, **kwargs)

        self.__attr = attr
Пример #12
0
    def __init__(self, attr='targets', **kwargs):
        """Initialize

        Parameters
        ----------
        attr : str
          Attribute to correlate across chunks.
        """
        # init base classes first
        FeaturewiseMeasure.__init__(self, **kwargs)

        self.__attr = attr
Пример #13
0
    def __init__(self, threshold=1.0e-2, kernel_width=1.0,
                 w_guess=None, **kwargs):
        """Constructor of the IRELIEF class.

        """
        # init base classes first
        FeaturewiseMeasure.__init__(self, **kwargs)

        # Threshold in W changes (stopping criterion for irelief).
        self.threshold = threshold
        self.w_guess = w_guess
        self.w = None
        self.kernel_width = kernel_width
Пример #14
0
    def __init__(self, pvalue=False, attr='targets', **kwargs):
        """Initialize

        Parameters
        ----------
        pvalue : bool
          Either to report p-value of pearsons correlation coefficient
          instead of pure correlation coefficient
        attr : str
          What attribut to correlate with
        """
        # init base classes first
        FeaturewiseMeasure.__init__(self, **kwargs)

        self.__pvalue = int(pvalue)
        self.__attr = attr
Пример #15
0
    def __init__(self, pvalue=False, attr='targets', **kwargs):
        """Initialize

        Parameters
        ----------
        pvalue : bool
          Either to report p-value of pearsons correlation coefficient
          instead of pure correlation coefficient
        attr : str
          What attribut to correlate with
        """
        # init base classes first
        FeaturewiseMeasure.__init__(self, **kwargs)

        self.__pvalue = int(pvalue)
        self.__attr = attr
Пример #16
0
    def __init__(self, datameasure, noise=np.random.normal):
        """
        Parameters
        ----------
        datameasure : `Measure`
          Used to quantify the effect of noise perturbation.
        noise: Callable
          Used to generate noise. The noise generator has to return an 1d array
          of n values when called the `size=n` keyword argument. This is the
          default interface of the random number generators in NumPy's
          `random` module.
        """
        # init base classes first
        FeaturewiseMeasure.__init__(self)

        self.__datameasure = datameasure
        self.__noise = noise
Пример #17
0
    def __init__(self, datameasure,
                 noise=np.random.normal):
        """
        Parameters
        ----------
        datameasure : `Measure`
          Used to quantify the effect of noise perturbation.
        noise: Callable
          Used to generate noise. The noise generator has to return an 1d array
          of n values when called the `size=n` keyword argument. This is the
          default interface of the random number generators in NumPy's
          `random` module.
        """
        # init base classes first
        FeaturewiseMeasure.__init__(self)

        self.__datameasure = datameasure
        self.__noise = noise
Пример #18
0
    def __init__(self, pvalue=False, attr='targets',
                        corr_backend=None, **kwargs):
        """Initialize

        Parameters
        ----------
        pvalue : bool
          Either to report p-value of pearsons correlation coefficient
          instead of pure correlation coefficient
        attr : str
          What attribut to correlate with
        corr_backend: None or 'builtin' or 'scipy' (default: None)
          Which function to use to compute correlations.
          None means 'scipy' if pvalue else 'builtin'. 
        """
        # init base classes first

        FeaturewiseMeasure.__init__(self, **kwargs)

        self.__pvalue = int(pvalue)
        self.__attr = attr
        self.__corr_backend = corr_backend
Пример #19
0
 def __init__(self, mult=1, **kwargs):
     FeaturewiseMeasure.__init__(self, **kwargs)
     self.__mult = mult
Пример #20
0
 def __init__(self, mult=1, **kwargs):
     FeaturewiseMeasure.__init__(self, **kwargs)
     self.__mult = mult