CVX MATLAB 包的稀疏组套索
Sparse Group lasso by CVX MATLAB package
有谁知道如何在 MATLAB 中使用 CVX、凸优化包实现稀疏组套索?
我不知道如何将公式描述为 CVX 原型。
我发现了一些东西here
我决定分享!!
一定要用CVX吗? Inria 在 mexproximalFlat 下有一个名为 Spams written in Matlab, R, and Python. If you want a group lasso regularizer look at the documentation in the proximal toolbox 的稀疏建模包。还有一些例子。我经常使用 python 垃圾邮件包。
(校正:两者都支持不同的组大小。nfs 中的示例通过使用附加约束支持不同的组大小。)
参考这个网页nfs给出的例子:
http://ask.cvxr.com/t/formulating-sparse-group-lasso-in-cvx/793/4
但是这个例子似乎不允许不同的组大小。你可以参考下面的例子
(使用的公式是 Simon、Noah 和 Robert Tibshirani 中的 Eq.3。"Standardization and the group lasso penalty." Statistica Sinica 22.3 (2012): 983.)
% Refer to Eq. (3) in /Simon, Noah, and Robert Tibshirani.
% "Standardization and the group lasso penalty."
% Statistica Sinica 22.3 (2012): 983./
% Note that group LASSO allows different group sizes
N = 64; m = 3;
rho = [2; 4; 6]; % group sizes
n = sum(rho); % num of total parameters
X = rand(N,n); % X = [X1, X2, ..., X_m]
y = rand(N,1);
lambda = 1;
IndexM = [1, 2; 3, 6; 7, 12]; % indexes of elements in each group
cvx_begin
% w = [beta1'; beta2'; ...; beta_m']
variable w(n)
expression ws(m)
for i = 1:m
ws(i) = norm(w(IndexM(i,1):IndexM(i,2)),2);
end
minimize( norm(y-X*w, 2) + lambda*(sqrt(rho)' * ws) )
cvx_end
% get beta_i, i.e. i-th beta corresponding to i-th group
% e.g.
i = 2;
beta_i = w(IndexM(i,1):IndexM(i,2));
我相信 CVX 无法轻松处理 SGL 中的组范数,除非您 hard-code 每个数据集的组范数。如果您使用的是 Matlab,则可以使用 SLEP toolbox.
有谁知道如何在 MATLAB 中使用 CVX、凸优化包实现稀疏组套索?
我不知道如何将公式描述为 CVX 原型。
我发现了一些东西here
我决定分享!!
一定要用CVX吗? Inria 在 mexproximalFlat 下有一个名为 Spams written in Matlab, R, and Python. If you want a group lasso regularizer look at the documentation in the proximal toolbox 的稀疏建模包。还有一些例子。我经常使用 python 垃圾邮件包。
(校正:两者都支持不同的组大小。nfs 中的示例通过使用附加约束支持不同的组大小。)
参考这个网页nfs给出的例子:
http://ask.cvxr.com/t/formulating-sparse-group-lasso-in-cvx/793/4
但是这个例子似乎不允许不同的组大小。你可以参考下面的例子
(使用的公式是 Simon、Noah 和 Robert Tibshirani 中的 Eq.3。"Standardization and the group lasso penalty." Statistica Sinica 22.3 (2012): 983.)
% Refer to Eq. (3) in /Simon, Noah, and Robert Tibshirani.
% "Standardization and the group lasso penalty."
% Statistica Sinica 22.3 (2012): 983./
% Note that group LASSO allows different group sizes
N = 64; m = 3;
rho = [2; 4; 6]; % group sizes
n = sum(rho); % num of total parameters
X = rand(N,n); % X = [X1, X2, ..., X_m]
y = rand(N,1);
lambda = 1;
IndexM = [1, 2; 3, 6; 7, 12]; % indexes of elements in each group
cvx_begin
% w = [beta1'; beta2'; ...; beta_m']
variable w(n)
expression ws(m)
for i = 1:m
ws(i) = norm(w(IndexM(i,1):IndexM(i,2)),2);
end
minimize( norm(y-X*w, 2) + lambda*(sqrt(rho)' * ws) )
cvx_end
% get beta_i, i.e. i-th beta corresponding to i-th group
% e.g.
i = 2;
beta_i = w(IndexM(i,1):IndexM(i,2));
我相信 CVX 无法轻松处理 SGL 中的组范数,除非您 hard-code 每个数据集的组范数。如果您使用的是 Matlab,则可以使用 SLEP toolbox.