/
demo_BNMC_unlabeled_data.m
61 lines (47 loc) · 1.37 KB
/
demo_BNMC_unlabeled_data.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
57
58
59
% Bayesian Nonparametric Multilabel Classification demo
clear all;
close all;
addpath(genpath(pwd))
%% loading data
fprintf('Loading Scene Data\n');
load('SceneData.mat');
if isempty(xxTrain) || isempty(xxTest)
return;
end
% convert from sparse to full matrix for fast matrix multiplication
yyTest=full(yyTest);
xxTrain=full(xxTrain);
xxTest=full(xxTest);
yyTrain=full(yyTrain);
%% plot the input data
figure;
imagesc(xxTrain);
set(gca,'fontsize',12);
ylabel('Data Points','fontsize',14);
xlabel('Features','fontsize',14);
title('Ground Truth Feature','fontsize',14);
figure;
imagesc(yyTrain);
set(gca,'fontsize',12);
ylabel('Data Points','fontsize',14);
xlabel('Classes','fontsize',14);
title('Ground Truth Label','fontsize',14);
%%
percentMissing=0.5; % selecting the missing portion ranges from 0-0.99
nTrain=size(yyTrain,1);
idx=randperm(nTrain);
cutpoint=floor(percentMissing*nTrain);
yyTrain(idx(1:cutpoint),:)=0;
%%
start=tic;
%options=11; % Batch Setting, SVM
options=12; % Batch Setting, LR
%options=21; % Online Setting, SVM
%options=22; % Online Setting, LR
[pred_yyTest] = BayNonMultilabelClass_unlabeled_data( xxTrain,yyTrain,xxTest,options );
mytime=toc(start);
%% Evaluation
[ Scores ] = MultiLabelEvaluation( yyTest,pred_yyTest );
F1Test=Scores.F1;
ExactScoreTest=Scores.ExactMatch;
fprintf(' F1=%.3f Exact=%.4f Running Time=%.1f\n',F1Test,ExactScoreTest,mytime);