信息检索评价指标mAP

MAP解释: https://blog.csdn.net/qq_25964837/article/details/78994993

代码实现:

单模态图像检索MAP、准确率、召回率

1、B = compactbit(H);
     tB = compactbit(tH);

H、tH分别表示图像库哈希码和测试图像哈希码。把 H 由位数组压缩成紧致的位串。

比如在SDH中把59000*32压缩为59000*4维。

matlab实现2进制转化为10进制:https://www.cnblogs.com/hxsyl/p/4591662.html

2、hammTrainTest=hammingDist(tB, B)‘

维度:59000*1000

Matlab计算两集合间的汉明距离:https://blog.csdn.net/weixin_34228617/article/details/90249342

3、Ret = (hammTrainTest <= hammRadius+0.00001);

     [Pre, Rec] = evaluate_macro(cateTrainTest, Ret)

使得hammTrainTest矩阵中值小于hammRadius+0.00001的位置取1,其他取0。hammRadius=2。

cateTrainTest表示标签,维度为59000*1000,只含0和1,同类处为1。

返回准确率和召回率。

4、[~, HammingRank]=sort(hammTrainTest,1);
     MAP = cat_apcal(traingnd,testgnd,HammingRank)

先把各列升序排列,[sA,index] = sort(A) ,排序后,sA是排序好的向量,index 是 向量sA 中对 A 的索引。

返回MAP。

跨模态图像文本检索MAP、准确率、召回率

  • [ map, prc, topK ] = calcAll( tselLabel, trainLabel, testInstance, trainInstance, K )   K:前K(i)个

1、压缩哈希码(与单模态相同)

    testInstance = bitCompact( testInstance >= 0 );
    trainInstance = bitCompact( trainInstance >= 0 );

2、求MAP / 只取检索出的前K(i)个检索数据的MAP、准确率、召回率

    if exist('K', 'var')
        topK = calcMapTopkMapTopkPreTopkRecLabel( tselLabel, trainLabel, testInstance, trainInstance, K );
        map = topK.map;
    else
        map = calcMapTopkMapTopkPreTopkRecLabel( tselLabel, trainLabel, testInstance, trainInstance ); %没有K的情况下直接求MAP。好像写错了,应该是result.map
        topK = 0;
    end

3、 计算不同的距离半径得到的准确率和召回率

    prc = calcPreRecRadiusLabel( tselLabel, trainLabel, testInstance, trainInstance );

  • [ result ] = calcAll_R(tselLabel, trainLabel, testInstance, trainInstance,R)   R:不同的半径R(i),如1~32

result:包括四个字段 map,topkMap,topkPre,topkRec(前R个汉明距离检索结果的map,精确率,召回率)

 

你可能感兴趣的:(信息检索评价指标mAP)