Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

How to specify groups for the group lasso penalty? #39

Open
fabianp opened this issue Nov 4, 2015 · 4 comments
Open

How to specify groups for the group lasso penalty? #39

fabianp opened this issue Nov 4, 2015 · 4 comments

Comments

@fabianp
Copy link
Member

fabianp commented Nov 4, 2015

It is stated that the CDClassifier object supports a group lasso ("l1/l2") penalty, yet it is not clear to me how the groups in the group penalty are specified.

@mblondel
Copy link
Member

mblondel commented Nov 4, 2015

It's only supported for multiclass classification and multitask classification / regression. The groups are the weights of a feature in all classes / tasks. This question comes up all the time. We need to improve the documentation.

@zht012323
Copy link

May i know this problem have been solved ? It is not clear to distinguish the group which have the same group penalty.In another word,in lamda*sum(sqrt(p))||beta||_2^2 , in CDClassifier which paremeter is defined each group size p.thanks

@fabianp
Copy link
Member Author

fabianp commented Sep 3, 2017

@zht012323 there hasn't been any progress on this

@8bit-pixies
Copy link

8bit-pixies commented Dec 7, 2017

Would defining a custom penalty and using FISTA partially "solve" this problem by basically rolling our own custom penalty?

Not sure if my "group penalty" actually makes sense in this context, but suppose we have two groups of coefficients off a dataset with 40 coefficients. One group being the first 20 indices, and the 2nd group being the second 20 indices.

Would one way to do Group Lasso be to define the penalty as:

class L1Penalty1(object):
    def __init__(self, group=[]):
        self.group = group
        
    def projection(self, coef, alpha, L):
        #np.sign(coef) * np.maximum(np.abs(coef) - alpha / L, 0)
        coef_group = coef.flatten().copy()
        for gp in self.group:
            gp_ = np.sum(np.abs(coef_group[gp]))
            coef_group[gp] = gp_
        coef_group = (coef_group/np.sum(coef_group)) * coef_group.shape[0]
        coef_group = coef_group.reshape(1, -1)
        #print(coef_group)
        #print(np.sum(coef_group))
        #print("---\n")
        
        reg_ = np.sum(np.abs(coef))
        projl1_ = np.sign(coef) * np.maximum(np.abs(coef) - alpha / L, 0) * coef_group
        return projl1_* (reg_/np.sum(np.abs(projl1_)))

    def regularization(self, coef):
        return np.sum(np.abs(coef))

Would this work?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants