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

qualityMeasures.Coverage Maven / Gradle / Ivy

Go to download

A Java's Collaborative Filtering library to carry out experiments in research of Collaborative Filtering based Recommender Systems. The library has been designed from researchers to researchers.

The newest version!
package cf4j.qualityMeasures;

import cf4j.TestUser;

/**
 * 

This class calculates the Coverage of the recommender system. The coverage is the capacity of * the recommender system to recommend new items. It is calculates as follows:

* *

coverage = <number of predicted items> / <number of items not rated by the user>

* *

This class puts the "Coverage" key at the Kernel map containing a double with the coverage * value.

* * @author Fernando Ortega */ public class Coverage extends QualityMeasure { private final static String NAME = "Coverage"; /** * Constructor of Coverage */ public Coverage () { super(NAME); } @Override public double getMeasure (TestUser testUser) { double [] predictions = testUser.getPredictions(); int count = 0; for (int i = 0; i < predictions.length; i++) { double prediction = predictions[i]; if (!Double.isNaN(prediction)) { count++; } } double coverage = (double) count / (double) testUser.getNumberOfTestRatings(); return coverage; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy