Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Predictionio optimization

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

There is something wrong with the validScores method of predictionio, because one of the attribute types in the model object is Map items, which must not work when there is a large amount of data, so optimize it and use the mode of join+filter. The code is as follows

Return all.mapToPair (new PairFunction () {@ Override public Tuple2 call (ItemScore idUser) throws Exception {return new Tuple2 (idUser.getItemEntityId (), idUser)) ) .join (model.getItems ()) .filter (new Function () {@ Override public Boolean call (Tuple2 itemScore) throws Exception {/ * Item item = items.get (itemScore.getItemEntityId ()); * / Item item = itemScore._2._2; / / logger.info ("join end") Return (whitelist, itemScore._2._1.getItemEntityId ()) & & passBlacklistCriteria (blacklist, itemScore._2._1.getItemEntityId ()) / * & & passCategoryCriteria (categories, item) * / / * & & passUnseenCriteria (seenItemEntityIds) ItemScore.getItemEntityId () * / / those you have seen or bought do not / * & & passAvailabilityCriteria (unavailableItemEntityIds, itemScore.getItemEntityId ()) * /) ) .map (new Function () {@ Override public ItemScore call (Tuple2 userItemCount) throws Exception {return userItemCount._2._1;}})

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report