I am a beginner, and I am trying to use the Lasso to do some regression. I am looking specifically at the LassoLars module in sklearn. What I am really after is recovering the parameter weight vector that is represented by
model.coef_. The trouble I am seeing that the weight vector always comes back as a zero vector. Since this is an optimization problem without constraints I figured it should at least return some weights in the parameter for some test data that I'm using.
So i have assumed the the
y vector in the Lasso objective function is represented by the rho * vector of ones ( where rho is the mean ). Thats why I have y the way it is as all the same.
The question I have is, is this the right way to use the Lasso to minimize this objective function?
I put together this short example to show my issue. Thanks
import numpy as np X = np.array( [[ 5.98976150e-03, -1.20984151e-02, -1.22465812e-02, 3.18018512e-03, -1.75622040e-03, -1.42396473e-03, 1.50766424e-03, -3.35345720e-03, 5.19307642e-03], [-3.37106026e-03, -6.89156129e-05, 4.81265968e-03, 5.60838622e-03, 1.22018867e-02, -1.52073535e-02, -1.75285697e-02, -1.51518050e-02, 2.40028354e-03], [-4.05015849e-03, 6.54103374e-03, -4.81555664e-03, 1.72384072e-04, 5.54351348e-03, -7.61408621e-03, 3.45393320e-04, -1.55521027e-03, 2.84937377e-03], [ 6.82272529e-03, -3.96931710e-03, 1.42365666e-03, -1.07870768e-02, 3.29016538e-03, 5.47946576e-03, -1.84030370e-02, -6.61630991e-03, 1.03000002e-02], [-5.59911877e-03, -2.04196233e-04, 2.90586730e-03, -1.16229772e-02, 1.57885915e-02, -3.50405356e-03, -2.56087364e-02, -3.56488119e-02, 2.97032595e-03]]) n = np.shape( X ) y = [np.mean(X)] * n from sklearn.linear_model import LassoLars from sklearn.preprocessing import StandardScaler model = LassoLars(alpha = 1) model.fit(X.T, y ) print( model.coef_ )