-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPARM_predict.m
24 lines (23 loc) · 940 Bytes
/
PARM_predict.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
function accuracy = PARM_predict(test_data,test_target,model)
%
% This function is the testing of the PARM algorithm.
%
% Syntax
%
% accuracy = PARM_predict(test_data,test_target,model)
%
% Description
%
% PARM_predict takes,
% test_data - A TxN array, the instance of the i-th testing example is stored in test_data(i,:)
% test_target - A QxT array, if the jth class label is the ground-truth label for the i-th testing example, then test_target(j,i) equals +1, otherwise train_p_target(j,i) equals 0
% model - The trained model
%
% and returns,
% accuracy - The testing accuracy
%
test_num = size(test_data,1);
output_test_value = model.W*test_data';
[~,pred_label] = max(output_test_value);
[~,real] = max(full(test_target));
accuracy = sum(pred_label==real)/test_num;