Skip to content

Gram-based CD/BCD/FISTA solvers for (group)Lasso when n_samples >> n_features #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix primal comp
  • Loading branch information
PABannier committed Apr 25, 2022
commit bfae08829c63e0dd63296f8dce57ba23b262b6ca
10 changes: 9 additions & 1 deletion skglm/solvers/gram.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@

@njit
def primal(alpha, r, w, weights):
n_features = len(weights)
p_obj = (r @ r) / (2 * len(r))
return p_obj + alpha * np.sum(np.abs(w * weights))
pen = 0.
for j in range(n_features):
if weights[j] == np.inf:
continue
pen += np.abs(w[j] * weights[j])
return p_obj + alpha * pen


@njit
def primal_grp(alpha, norm_r2, r, w, grp_ptr, grp_indices, weights):
p_obj = norm_r2 / (2 * len(r))
for g in range(len(grp_ptr) - 1):
if weights[g] == np.inf:
continue
w_g = w[grp_indices[grp_ptr[g]:grp_ptr[g + 1]]]
p_obj += alpha * norm(w_g * weights[g], ord=2)
return p_obj
Expand Down