glm-tools / pyglmnet

Python implementation of elastic-net regularized generalized linear models
http://glm-tools.github.io/pyglmnet/
MIT License
279 stars 83 forks source link

The trained weight is not sparse at all #296

Closed ChrisRBXiong closed 5 years ago

ChrisRBXiong commented 5 years ago

I am using the module to train the group lasso model. `glm = GLM(distr = 'binomial', group=group_idxes, learning_rate = 10-2.771705845919422, verbose = True, max_iter=3, reg_lambda = 101.2213650257009823, solver = 'cdfast', tol = 1e-3, alpha = 1.0, random_state = 2019)

glm.fit(train_X, train_y)`

The accuracy of the trained model is quite well, but the trained weight is not sparse at all. Even I use very large reg_lambda. I'm wondering that is my usage correct?

Each group has 768 features, and the 2-norm of each group is as follows:

0.7055740935825433 0.6654135773102396 0.6925086284060665 0.625103863034743 0.5874178057768213 0.5858135592984621 0.5382990539943326 0.5114795842048324 0.5104585530478004 0.49073420861969896 0.4693630261332302 0.47730209880877605

Besides, there's no weight is equal to zero. The 100-percentiles of all weights are: [3.37132626e-04 6.54944827e-04 1.00657159e-03 1.35317347e-03 1.66078961e-03 1.94143414e-03 2.31119584e-03 2.69599030e-03 3.05196232e-03 3.44671895e-03 3.77644024e-03 4.16328368e-03 4.55276889e-03 4.93319087e-03 5.34677732e-03 5.69570195e-03 6.07786409e-03 6.45700361e-03 6.94750713e-03 7.37769881e-03 7.85865455e-03 8.26466518e-03 8.75182496e-03 9.21303059e-03 9.54850153e-03 1.00828079e-02 1.05538342e-02 1.09895134e-02 1.14388994e-02 1.20089153e-02 1.25178156e-02 1.30433057e-02 1.35519063e-02 1.42211434e-02 1.47938031e-02 1.53881591e-02 1.60422446e-02 1.66271978e-02 1.72104265e-02 1.78752799e-02 1.84999348e-02 1.91477511e-02 1.97234645e-02 2.03432646e-02 2.11947991e-02 2.18948041e-02 2.28222716e-02 2.35978739e-02 2.44896833e-02 2.52522429e-02 2.61390958e-02 2.70019433e-02 2.77533770e-02 2.86792313e-02 2.98048632e-02 3.07998964e-02 3.17874964e-02 3.27359351e-02 3.39244881e-02 3.49313031e-02 3.63534001e-02 3.78252901e-02 3.90804851e-02 4.03501603e-02 4.16454693e-02 4.29544953e-02 4.42441911e-02 4.55344084e-02 4.70655201e-02 4.87801195e-02 5.04620439e-02 5.20684628e-02 5.37796145e-02 5.59044030e-02 5.80183801e-02 5.99386137e-02 6.17447616e-02 6.40085676e-02 6.62926993e-02 6.87979063e-02 7.17769057e-02 7.52612569e-02 7.85958384e-02 8.20817220e-02 8.63971994e-02 9.00593039e-02 9.37907314e-02 9.94380008e-02 1.04580123e-01 1.08925503e-01 1.15440829e-01 1.23283166e-01 1.32638972e-01 1.46531083e-01 1.59461238e-01 1.81886245e-01 2.11999525e-01 2.52034096e-01 3.42400735e-01 1.74976714e+00]

Thanks a lot !

jasmainak commented 5 years ago

looks correct to me. Can you provide a code snippet that I can run and try on my computer to see what's the issue?

jasmainak commented 5 years ago

and can you try using the development version. It might already be fixed because of https://github.com/glm-tools/pyglmnet/pull/249/

ChrisRBXiong commented 5 years ago

Thanks a lot! The development version is worked. The problem is solved.