-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMDFS.m
57 lines (45 loc) · 1.97 KB
/
MDFS.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
function [ W, obj ] = MDFS( X_train, Y_train, para )
%% function discription
% ----------------------------------------------------------------------
% Function for multi-label feature selection
% Jia Zhang
% Inputs:
% X_train--A n x m array, the i-th instance is stored in X_train(i,:)
% Y_train--A n x q array, q is the number of possible labels, Y_train(i,j) is 1 if the i-th instance has the j-th label, and -1 otherwise
%
% para--the set of parameters
%
% Outputs:
% W--A d x q array, d is the number of features, coefficient matrix for feature selection
%
% obj--The objective values
%
% ----------------------------------------------------------------------
% Calucate some statitics about the data
[num_train, num_feature] = size(X_train); num_label = size(Y_train, 2);
%L, L0, and H
L = Laplacian_GK(X_train', para); L0 = Laplacian_GK(Y_train, para);
H = eye(num_train) - 1 / num_train * ones(num_train, 1) * ones(num_train, 1)';
%Initialize W
W = rand(num_feature, num_label);
W1 = rand(num_feature, 1);
iter = 1; obji = 1;
while 1
%Update F--------------------------------------------------------------
A = L + para.alpha * H + para.alpha * eye(num_train);
B = para.beta * L0;
C = - para.alpha * H * X_train * W - para.alpha * Y_train;
F = lyap(A, B, C);
F1 = inv(A)*(para.alpha * H * X_train * W1);
%Update W--------------------------------------------------------------
d = 0.5./sqrt(sum(W.*W, 2) + eps);
D = diag(d);
W = (para.alpha * X_train' * H * X_train + para.gamma * D + eps*eye(num_feature)) \ (para.alpha * X_train' * H * F);
obj(iter) = trace(F'*L*F) + para.alpha*(norm((H*X_train*W - H*F), 'fro'))^2 + para.alpha*(norm((F - Y_train), 'fro'))^2 ...
+ para.beta*trace(F*L0*F') + para.gamma * sum(sqrt(sum(W.*W,2)+eps));
cver = abs((obj(iter) - obji)/obji);
obji = obj(iter);
iter = iter + 1;
if (cver < 10^-3 && iter > 2) , break, end
end
end