-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnnotate_MCDL.m
58 lines (53 loc) · 2.05 KB
/
Annotate_MCDL.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
close all;clear all;
path = [pwd,'/Inputs/'];
[filename, pathname] = uigetfile('*.mat', 'Select the result File');
mat_file = fullfile(pathname, filename);
load(mat_file);
%%
use_my_threshold = false;
my_threshold = 0.4;
%% If Features are raw, below flag should be true
need_normalize = false;
%% To Run this script, please put .mat file in the Inputs folder
% Library mex files are compiled for win 64. To run in another operating
% system, you should compile spams-matlab library
% path = [pwd,'/Inputs/'];
%%
warning off;
addpath(genpath('spams-matlab'));
addpath(genpath('measures'));
%%
if(use_my_threshold)
threshold = my_threshold;
else
threshold = result.threshold;
end
disp(['Threshold Value for Prediction = ', num2str(threshold)]);
%% Assign train and test from result structure
train = result.train;
test = result.test;
%% Normalization
%% Dimensionally Reduction & Normalization
if(size(train, 2)~=pcaDim)
pca_map.mean = mean(train);
train = bsxfun(@minus,train,pca_map.mean);
test = bsxfun(@minus,test,pca_map.mean);
[pca_map.P, ~] = pca(train,'NumComponents', pcaDim); %% PCA Transformed Data
train = train*pca_map.P;
test = test*pca_map.P;
clear pcaBasis;
end
train = normc(single(train'));
test = normc(single(test'));
%% Test Similarity and Performance Computing
alphaTest = mexLasso(test,result.D_Input, result.param);
test_similarity = result.D_Label*full(alphaTest);
test_predict = test_similarity>threshold;
[precision,recall,F1]=f1Computing(result.testAnnotation, test_predict);
disp([' Test Precision = ', num2str(precision), ' Recall = ', num2str(recall), ' F1 = ', num2str(F1)]);
%% Train Similarity and Performance Computing
alphaTrain = mexLasso(train,(result.D_Input), result.param);
train_similarity = result.D_Label*full(alphaTrain);
train_predict = train_similarity>threshold;
[precision,recall,F1]=f1Computing(result.trainAnnotation, train_predict);
disp([' Train Precision = ', num2str(precision), ' Recall = ', num2str(recall), ' F1 = ', num2str(F1)]);