function [pre, rec, f] = F1measure(y, h)
%y: the actual labels of the test instances, if the ith instance belong to the positive class, y(1,i)=1, otherwise y(1,i)=0
%h: the predicted labels of the classifier, if the ith instance belong to the positive class, h(1,i)=1, otherwise h(1,i)=0

    TP = sum(y & h);
    FP = sum((~y) & h);
    FN = sum(y & (~h));

    pre = TP / (TP + FP + 1e-6); 
    rec = TP / (TP + FN + 1e-6);
    f = 2 * pre * rec / (pre + rec + 1e-6);

end

