本文整理汇总了Java中org.grouplens.lenskit.data.event.Rating类的典型用法代码示例。如果您正苦于以下问题:Java Rating类的具体用法?Java Rating怎么用?Java Rating使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Rating类属于org.grouplens.lenskit.data.event包,在下文中一共展示了Rating类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeUserVector
import org.grouplens.lenskit.data.event.Rating; //导入依赖的package包/类
private SparseVector makeUserVector(long user) {
// Get the user's ratings
List<Rating> userRatings = dao.getEventsForUser(user, Rating.class);
if (userRatings == null) {
// the user doesn't exist
return SparseVector.empty();
}
// Create a new vector over tags to accumulate the user profile
MutableSparseVector profile = model.newTagVector();
// Fill it with 0's initially - they don't like anything
profile.fill(0);
// Iterate over the user's ratings to build their profile
for (Rating r: userRatings) {
// In LensKit, ratings are expressions of preference
Preference p = r.getPreference();
// We'll never have a null preference. But in LensKit, ratings can have null
// preferences to express the user unrating an item
if (p != null && p.getValue() >= 3.5) {
// The user likes this item!
// Get the item's vector and add it to the user's profile
SparseVector iv = model.getItemVector(p.getItemId());
profile.add(iv);
}
}
// The profile is accumulated, return it.
// It is good practice to return a frozen vector.
return profile.freeze();
}
开发者ID:4DD8A19D69F5324F9D49D17EF78BBBCC,项目名称:Introd_uction_to_Recom_mander_S_ystem,代码行数:32,代码来源:TFIDFItemScorer.java
示例2: getUserRatingVector
import org.grouplens.lenskit.data.event.Rating; //导入依赖的package包/类
/**
* Get a user's ratings.
* @param user The user ID.
* @return The ratings to retrieve.
*/
private SparseVector getUserRatingVector(long user) {
UserHistory<Rating> history = userEvents.getEventsForUser(user, Rating.class);
if (history == null) {
history = History.forUser(user);
}
return RatingVectorUserHistorySummarizer.makeRatingVector(history);
}
开发者ID:4DD8A19D69F5324F9D49D17EF78BBBCC,项目名称:Introd_uction_to_Recom_mander_S_ystem,代码行数:14,代码来源:SimpleItemItemScorer.java
示例3: getUserRatingVector
import org.grouplens.lenskit.data.event.Rating; //导入依赖的package包/类
/**
* Get a user's rating vector.
* @param user The user ID.
* @return The rating vector.
*/
private SparseVector getUserRatingVector(long user) {
UserHistory<Rating> history = userDao.getEventsForUser(user, Rating.class);
if (history == null) {
history = History.forUser(user);
}
return RatingVectorUserHistorySummarizer.makeRatingVector(history);
}
开发者ID:4DD8A19D69F5324F9D49D17EF78BBBCC,项目名称:Introd_uction_to_Recom_mander_S_ystem,代码行数:13,代码来源:SimpleUserUserItemScorer.java
示例4: makeUserVector
import org.grouplens.lenskit.data.event.Rating; //导入依赖的package包/类
private SparseVector makeUserVector(long user) {
// Get the user's ratings
List<Rating> userRatings = dao.getEventsForUser(user, Rating.class);
if (userRatings == null) {
// the user doesn't exist
return SparseVector.empty();
}
// Create a new vector over tags to accumulate the user profile
MutableSparseVector profile = model.newTagVector();
// Fill it with 0's initially - they don't like anything
profile.fill(0);
// Iterate over the user's ratings to build their profile
for (Rating r: userRatings) {
// In LensKit, ratings are expressions of preference
Preference p = r.getPreference();
// We'll never have a null preference. But in LensKit, ratings can have null
// preferences to express the user unrating an item
if (p != null && p.getValue() >= 3.5) {
SparseVector sparseVectorForItem = model.getItemVector(p.getItemId());
profile.add(sparseVectorForItem);
}
}
// The profile is accumulated, return it.
// It is good practice to return a frozen vector.
return profile.freeze();
}
示例5: getUserRatingVector
import org.grouplens.lenskit.data.event.Rating; //导入依赖的package包/类
/**
* Get a user's ratings.
* @param user The user ID.
* @return The ratings to retrieve.
*/
private SparseVector getUserRatingVector(long user) {
UserHistory<Rating> history = userEvents.getEventsForUser(user, Rating.class);
if (history == null) {
history = History.forUser(user);
}
return RatingVectorUserHistorySummarizer.makeRatingVector(history);
}
示例6: getUserRatingVector
import org.grouplens.lenskit.data.event.Rating; //导入依赖的package包/类
/**
* Get a user's rating vector
* @param user The user ID
* @return The rating vector
*/
private SparseVector getUserRatingVector(long user) {
UserHistory<Rating> history = userDao.getEventsForUser(user, Rating.class);
if (history == null) {
history = History.forUser(user);
}
return RatingVectorUserHistorySummarizer.makeRatingVector(history);
}
示例7: createRatingMatrix
import org.grouplens.lenskit.data.event.Rating; //导入依赖的package包/类
/**
* Build a rating matrix from the rating data. Each user's ratings are first normalized
* by subtracting a baseline score (usually a mean).
*
* @param userMapping The index mapping of user IDs to column numbers.
* @param itemMapping The index mapping of item IDs to row numbers.
* @return A matrix storing the <i>normalized</i> user ratings.
*/
private RealMatrix createRatingMatrix(IdIndexMapping userMapping, IdIndexMapping itemMapping) {
final int nusers = userMapping.size();
final int nitems = itemMapping.size();
// Create a matrix with users on rows and items on columns
logger.info("creating {} by {} rating matrix", nusers, nitems);
RealMatrix matrix = MatrixUtils.createRealMatrix(nusers, nitems);
// populate it with data
Cursor<UserHistory<Event>> users = userEventDAO.streamEventsByUser();
try {
for (UserHistory<Event> user: users) {
// Get the row number for this user
int u = userMapping.getIndex(user.getUserId());
MutableSparseVector ratings = Ratings.userRatingVector(user.filter(Rating.class));
MutableSparseVector baselines = MutableSparseVector.create(ratings.keySet());
baselineScorer.score(user.getUserId(), baselines);
for(VectorEntry v : ratings.fast())
{
matrix.setEntry(u, itemMapping.getIndex(v.getKey()), v.getValue() - baselineScorer.score(user.getUserId(), v.getKey()));
}
}
} finally {
users.close();
}
return matrix;
}
示例8: getUserRatingVector
import org.grouplens.lenskit.data.event.Rating; //导入依赖的package包/类
/**
* Get a user's ratings.
*
* @param user
* The user ID.
* @return The ratings to retrieve.
*/
private SparseVector getUserRatingVector(long user) {
UserHistory<Rating> history = userEvents.getEventsForUser(user,
Rating.class);
if (history == null) {
history = History.forUser(user);
}
return RatingVectorUserHistorySummarizer.makeRatingVector(history);
}