Skip to content

Commit

Permalink
Made changes to follow pep-8
Browse files Browse the repository at this point in the history
  • Loading branch information
yngvem committed Jul 18, 2020
1 parent 14ff421 commit 5264f0d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/group_lasso/_fista.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def minimise(self, x0, n_iter=10, tol=1e-6, callback=None):
generalised_gradient = momentum_x.ravel() - new_optimal_x.ravel()
update_vector = new_optimal_x.ravel() - previous_x.ravel()
# Loss based restart criterion
if self.smooth_loss(new_optimal_x) > self.smooth_loss(previous_x):
if generalised_gradient.T@update_vector > 0:
momentum_x = previous_x
momentum = 1
(
Expand Down
12 changes: 6 additions & 6 deletions src/group_lasso/_group_lasso.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def _split_intercept(w):


def _join_intercept(b, w):
m, n = w.shape
return np.concatenate([np.array(b).reshape(1, n), w], axis=0)
num_classes = w.shape[1]
return np.concatenate([np.array(b).reshape(1, num_classes), w], axis=0)


def _add_intercept_col(X):
Expand Down Expand Up @@ -193,10 +193,10 @@ def _regulariser(self, w):
is sliced away.
"""
regulariser = 0
b, w = _split_intercept(w)
coef_ = _split_intercept(w)[1]
for group, reg in zip(self.groups_, self.group_reg_vector_):
regulariser += reg * la.norm(w[group])
regulariser += self.l1_reg * la.norm(w.ravel(), 1)
regulariser += reg * la.norm(coef_[group])
regulariser += self.l1_reg * la.norm(coef_.ravel(), 1)
return regulariser

def _get_reg_strength(self, group, reg):
Expand Down Expand Up @@ -654,7 +654,7 @@ def _grad(self, X_aug, y, w):
return SSE_grad / X_aug.shape[0]

def _estimate_lipschitz(self, X_aug, y):
num_rows, num_cols = X_aug.shape
num_rows = X_aug.shape[0]
if self.frobenius_lipchitz:
if sparse.issparse(X_aug):
return sparse.linalg.norm(X_aug, "fro") ** 2 / num_rows
Expand Down

0 comments on commit 5264f0d

Please sign in to comment.