通过Mahout构建推荐系统时,如果我们需要加入某些过滤规则(比如:item的创建时间在一年以内),则需要用到
IDRescorer
接口,该接口源码如下:
package org.apache.mahout.cf.taste.recommender;
/**
* <p>
* A {@link Rescorer} which operates on {@code long} primitive IDs, rather than arbitrary {@link Object}s.
* This is provided since most uses of this interface in the framework take IDs (as {@code long}) as an
* argument, and so this can be used to avoid unnecessary boxing/unboxing.
* </p>
*/
public interface IDRescorer {
/**
* @param id
* ID of thing (user, item, etc.) to rescore
* @param originalScore
* original score
* @return modified score, or {@link Double#NaN} to indicate that this should be excluded entirely
*/
double rescore(long id, double originalScore);