supervised discrete hashing的evaluate_macro代码理解：在主程序中调用时，evaluate_macro的前一个输入参数是cateTrainTest，是训练样本数*测试样本数的矩阵。evaluate_macro函数体中，对每个测试样本，retrieved_relevant_num代表TP；relevant_num代表TP+FN；retrieved_num代表TP+FP。所有样本分别的平均precision即是最终的输出precision，所有样本分别的平均recall即是最终的输出recall。
cat_apcal函数是计算MAP的，代码意义很好理解，比如按距离排序，前七个只有1、3、5和7是和query相同的类，则MAP=(1+2/3+3/5+4/7)/4 (This is with discussing with Shu Zhang). 但Deep hashing for compact (CVPR 2015) mean average
precision (mAP): which computes the area under the precision-recall curve.
matlab曲线下如何求面积?

Shu Zhang说不知以上两种是否等价，如果按照Deep hashing for compact (CVPR 2015)算面积，则直接就能看出不同的方法谁的MAP大，因为谁的曲线在上方就谁大

Reference

http://www.mathworks.com/matlabcentral/fileexchange/37758-performance-measures-for-classification/content/Evaluate.m

```function EVAL = Evaluate(ACTUAL,PREDICTED)
% This fucntion evaluates the performance of a classification model by
% calculating the common performance measures: Accuracy, Sensitivity,
% Specificity, Precision, Recall, F-Measure, G-mean.
% Input: ACTUAL = Column matrix with actual class labels of the training
%                 examples
%        PREDICTED = Column matrix with predicted class labels by the
%                    classification model
% Output: EVAL = Row matrix with all the performance measures

idx = (ACTUAL()==1);

p = length(ACTUAL(idx));
n = length(ACTUAL(~idx));
N = p+n;

tp = sum(ACTUAL(idx)==PREDICTED(idx));
tn = sum(ACTUAL(~idx)==PREDICTED(~idx));
fp = n-tn;
fn = p-tp;

tp_rate = tp/p;
tn_rate = tn/n;

accuracy = (tp+tn)/N;
sensitivity = tp_rate;
specificity = tn_rate;
precision = tp/(tp+fp);
recall = sensitivity;
f_measure = 2*((precision*recall)/(precision + recall));
gmean = sqrt(tp_rate*tn_rate);

EVAL = [accuracy sensitivity specificity precision recall f_measure gmean];```