EugeneNdiaye / smoothed_concomitant_lasso

Joint estimation of location and scale parameters with l1 regularization.
http://iopscience.iop.org/article/10.1088/1742-6596/904/1/012006/meta
2 stars 4 forks source link

Cannot use score() function of SCregressor #9

Open mathurinm opened 4 years ago

mathurinm commented 4 years ago

Hello @EugeneNdiaye I tried to use clf.score(X, y) on your classifier but it breaks. I think it's because your estimator take multiple values of lambdas as input, so when it predicts it gives predictions for several lambdas/betas while sklearn expect only one y_pred to compare to y_true.

MCVE:

import numpy as np

from numpy.linalg import norm

from smoothconco.smoothed_concomitant import SCRegressor

X = np.random.randn(10, 10)
y = X @ np.random.randn(10)
X /= norm(X, axis=0)

n_samples, n_features = X.shape

alpha_max_conco = norm(X.T @ y, ord=np.inf) / \
    (norm(y) * np.sqrt(len(y)))
alphas = alpha_max_conco * np.geomspace(1, 0.1, num=10)

clf = SCRegressor(lambdas=alphas)
clf.fit(X, y)

print(clf.score(X, y))

ValueError: y_true and y_pred have different number of output (1!=100)

Let me know if I can help. @agramfort this may also be of interest to you.

EugeneNdiaye commented 4 years ago

Thanks Mathurin. I will have time to fix it after aistats deadline :-)