mathurinm / celer

Fast solver for L1-type problems: Lasso, sparse Logisitic regression, Group Lasso, weighted Lasso, Multitask Lasso, etc.
https://mathurinm.github.io/celer/
BSD 3-Clause "New" or "Revised" License
199 stars 33 forks source link

FIX primal computations with infinite weights #232

Closed mathurinm closed 2 years ago

mathurinm commented 2 years ago

@sehoff this explains why your case 3.1 was slow. use Lasso(verbose=1) or verbose=2 to get more info about the solver progress; here the primal objective was nan at first iteration, hence it was just running until the max number of iterations and epochs, so a very long time.

@Badr-MOUFAD have a look at this, when this is merged can you add a unit test testing this case for Lasso, LogisticRegression and GroupLasso ?

Basic script to reproduce the issue on main:

import numpy as np
from celer import Lasso, GroupLasso

np.random.seed(1)
X = np.random.randn(50, 60)
y = np.random.randn(50)

weights = np.ones(60)
weights[30:] = np.inf
alpha_max = np.max(np.abs(X.T @ y) / weights) / len(y)
clf = Lasso(alpha=alpha_max / 10, weights=weights,
            max_iter=1, max_epochs=20, verbose=2).fit(X, y)
codecov-commenter commented 2 years ago

Codecov Report

Merging #232 (0d6b37d) into main (32147a2) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #232   +/-   ##
=======================================
  Coverage   86.55%   86.55%           
=======================================
  Files          14       14           
  Lines         967      967           
  Branches      129      129           
=======================================
  Hits          837      837           
  Misses        100      100           
  Partials       30       30           
Flag Coverage Δ
unittests ∅ <ø> (∅)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 32147a2...0d6b37d. Read the comment docs.