示例#1
0
文件: gfb.py 项目: rafael-glima/tick
 def __init__(self, prox_list: list):
     # Range is stored in each Prox individually
     Prox.__init__(self, range=None)
     if len(prox_list) == 0:
         raise ValueError('prox_list must have at least one Prox')
     self.prox_list = prox_list
     self.n_proxs = len(self.prox_list)
示例#2
0
 def __init__(self,
              strength: float,
              n_rows: int = None,
              range: tuple = None,
              positive: bool = False):
     Prox.__init__(self, range)
     self.positive = positive
     self.strength = strength
     self.n_rows = n_rows
     self.rank_max = None
示例#3
0
 def __init__(self,
              strength: float,
              fdr: float = 0.6,
              range: tuple = None,
              positive: bool = False):
     Prox.__init__(self, range)
     self.strength = strength
     self.fdr = fdr
     self.positive = positive
     self.weights = None
     self._prox = self._build_cpp_prox("float64")
示例#4
0
 def __init__(self,
              strength: float,
              fdr: float = 0.6,
              range: tuple = None,
              positive: bool = False):
     Prox.__init__(self, range)
     self.strength = strength
     self.fdr = fdr
     self.positive = positive
     self.weights = None
     if range is None:
         self._prox = _ProxSlope(self.strength, self.fdr, self.positive)
     else:
         self._prox = _ProxSlope(self.strength, self.fdr, self.range[0],
                                 self.range[1], self.positive)
示例#5
0
    def set_prox(self, prox: Prox):
        """Set proximal operator in the solver

        Parameters
        ----------
        prox : `Prox`
            The proximal operator of the penalization function

        Returns
        -------
        output : `Solver`
            The solver with given prox

        Notes
        -----
        In some solvers, ``set_model`` must be called before
        ``set_prox``, otherwise and error might be raised
        """
        if not isinstance(prox, Prox):
            raise ValueError('Passed object of class %s is not a '
                             'Prox class' % prox.name)
        if self.dtype is None or self.model is None:
            raise ValueError("Solver must call set_model before set_prox")
        if prox.dtype != self.dtype:
            prox = prox.astype(self.dtype)
        self._set("prox", prox)
        return self
示例#6
0
 def __init__(self,
              strength: float,
              fdr: float = 0.6,
              weights_type: str = "bh",
              range: tuple = None,
              positive: bool = False):
     Prox.__init__(self, range)
     self.strength = strength
     self.fdr = fdr
     self.weights_type = weights_type
     self.positive = positive
     self.weights = None
     if range is None:
         self._prox = _ProxSortedL1(self.strength, self.fdr,
                                    self._weights_type, self.positive)
     else:
         self._prox = _ProxSortedL1(self.strength, self.fdr,
                                    self._weights_type, self.range[0],
                                    self.range[1], self.positive)
示例#7
0
 def set_prox(self, prox: Prox):
     if prox._prox is None:
         raise ValueError("Prox %s is not compatible with stochastic "
                          "solver %s" % (prox.__class__.__name__,
                                         self.__class__.__name__))
         # Give the C++ wrapped prox to the solver
     if self.dtype is None or self.model is None:
         raise ValueError("Solver must call set_model before set_prox")
     if prox.dtype != self.dtype:
         prox = prox.astype(self.dtype)
     self._solver.set_prox(prox._prox)
     return self
示例#8
0
 def _as_dict(self):
     dd = Prox._as_dict(self)
     del dd["weights"]
     return dd