def apply_prox_operator(self, x, gamma):
if self._lambda < 0:
logging.error("A negative regularisation parameter was used")
raise ValueError("A negative regularization parameter was used")
l = list(set().union(*self._groups))
if not (l == list(np.arange(x.shape[1]))):
logging.error("The groups in group lasso must cover all the "
"features")
raise ValueError("The groups in group lasso must cover all the "
"features")
for pair in combinations(self._groups, r=2):
if len(set(pair[0]) & set(pair[1])) > 0:
logging.error("There are overlapping groups")
raise ValueError("There are overlapping groups")
new_x = np.zeros_like(x)
for r in range(0, x.shape[0]):
for g in self._groups:
new_x[r, g] = self.prox_operator(x[r, g], gamma)
return new_x
评论列表
文章目录