package net.librec.recommender.ext;

import net.librec.annotation.ModelData;
import net.librec.common.LibrecException;
import net.librec.recommender.AbstractRecommender;

/**
 * Suppose that you have some predictive ratings (in "pred.txt") generated by an external recommender (e.g., some
 * recommender of MyMediaLite). The predictions are in the format of user-item-prediction. These predictions are
 * corresponding to a test set "test.txt" (user-item-held_out_rating). This class (ExternalRecommender) provides you
 * with the ability to compute predictive performance by setting the training set as "pred.txt" and the test set as
 * "test.txt". <br>
 * <br>
 * <p>
 * <strong>NOTE:</strong> This approach is not applicable to item recommendation. Thank {@literal Marcel Ackermann} for
 * bringing this demand to my attention.
 *
 * @author Guo Guibing and Keqiang Wang
 */
@ModelData({"isRating", "external", "trainMatrix"})
public class ExternalRecommender extends AbstractRecommender {
    @Override
    protected void trainModel() throws LibrecException {

    }

    /**
     * predict a specific rating for user userIdx on item itemIdx.
     *
     * @param userIdx user index
     * @param itemIdx item index
     * @return predictive rating for user userIdx on item itemIdx
     * @throws LibrecException if error occurs
     */
    @Override
    protected double predict(int userIdx, int itemIdx) throws LibrecException {
        return trainMatrix.get(userIdx, itemIdx);
    }
}
