All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.shijingsh.ai.evaluate.ranking.MRREvaluator Maven / Gradle / Ivy

The newest version!
package com.shijingsh.ai.evaluate.ranking;

import com.shijingsh.ai.evaluate.RankingEvaluator;

import com.shijingsh.ai.evaluate.RankingEvaluator;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntSet;

/**
 * 平均倒数排名评估器
 *
 * 
 * MRR = Mean Reciprocal Rank(平均倒数排名)
 * https://en.wikipedia.org/wiki/Mean_reciprocal_rank
 * 
* * @author Birdy */ public class MRREvaluator extends RankingEvaluator { public MRREvaluator(int size) { super(size); } @Override protected float measure(IntSet checkCollection, IntList rankList) { if (rankList.size() > size) { rankList = rankList.subList(0, size); } int size = rankList.size(); for (int index = 0; index < size; index++) { int itemIndex = rankList.get(index); if (checkCollection.contains(itemIndex)) { return 1F / (index + 1); } } return 0F; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy