jolars / slopecd

4 stars 2 forks source link

Issue when using hybrid solver on sparse matrix #47

Closed Klopfe closed 2 years ago

Klopfe commented 2 years ago

the code to replicate the error

import matplotlib.pyplot as plt
import numpy as np
from benchopt.datasets import make_correlated_data
from scipy import stats

from slope.data import get_data
from slope.solvers import hybrid_cd, oracle_cd, prox_grad, admm, newt_alm
from slope.utils import dual_norm_slope

dataset = "Rhee2006"
if dataset == "simulated":
    X, y, _ = make_correlated_data(n_samples=10, n_features=20, random_state=0)
    # X = csc_matrix(X)
else:
    X, y = get_data(dataset)

fit_intercept = True

randnorm = stats.norm(loc=0, scale=1)
q = 0.1
reg = 0.01

alphas_seq = randnorm.ppf(1 - np.arange(1, X.shape[1] + 1) * q / (2 * X.shape[1]))

alpha_max = dual_norm_slope(X, (y - fit_intercept * np.mean(y)) / len(y), alphas_seq)

alphas = alpha_max * alphas_seq * reg
plt.close("all")

max_epochs = 10000
max_time = 100
verbose = True
fit_interecpt = True

tol = 1e-4

beta_cd, intercept_cd, primals_cd, gaps_cd, time_cd = hybrid_cd(
    X,
    y,
    alphas,
    fit_intercept=fit_intercept,
    max_epochs=max_epochs,
    verbose=verbose,
    tol=tol,
    max_time=max_time,
    use_reduced_X=False
)
jolars commented 2 years ago

No, I am not actually seeing an error on my side. What is the error you're getting?

Klopfe commented 2 years ago

Updating numba fixed the problem.