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

ciir.umass.edu.metric.DCGScorer Maven / Gradle / Ivy

/*===============================================================================
 * Copyright (c) 2010-2012 University of Massachusetts.  All Rights Reserved.
 *
 * Use of the RankLib package is subject to the terms of the software license set 
 * forth in the LICENSE file included with this software, and also available at
 * http://people.cs.umass.edu/~vdang/ranklib_license.html
 *===============================================================================
 */

package ciir.umass.edu.metric;

import ciir.umass.edu.learning.RankList;
import ciir.umass.edu.utilities.SimpleMath;

public class DCGScorer extends MetricScorer {
	
	protected static double[] discount = null;//cache
	protected static double[] gain = null;//cache
	
	public DCGScorer()
	{
		this.k = 10;
		//init cache if we haven't already done so
		if(discount == null)
		{
			discount = new double[5000];
			for(int i=0;i rl.size() || k <= 0)
			size = rl.size();
		
		int[] rel = getRelevanceLabels(rl);
		return getDCG(rel, size);
	}
	public double[][] swapChange(RankList rl)
	{
		int[] rel = getRelevanceLabels(rl);
		int size = (rl.size() > k) ? k : rl.size();
		double[][] changes = new double[rl.size()][];
		for(int i=0;i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy