當前位置: 首頁>>代碼示例>>Python>>正文


Python models.AddonRecommendation類代碼示例

本文整理匯總了Python中addons.models.AddonRecommendation的典型用法代碼示例。如果您正苦於以下問題:Python AddonRecommendation類的具體用法?Python AddonRecommendation怎麽用?Python AddonRecommendation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了AddonRecommendation類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_scores

 def test_scores(self):
     ids = [5299, 1843, 2464, 7661, 5369]
     scores = AddonRecommendation.scores(ids)
     q = AddonRecommendation.objects.filter(addon__in=ids)
     for addon, recs in itertools.groupby(q, lambda x: x.addon_id):
         for rec in recs:
             eq_(scores[addon][rec.other_addon_id], rec.score)
開發者ID:jaliste,項目名稱:zamboni,代碼行數:7,代碼來源:test_models.py

示例2: build_recs

 def build_recs(cls, addon_ids):
     """Get the top ranking add-ons according to recommendation scores."""
     scores = AddonRecommendation.scores(addon_ids)
     d = collections.defaultdict(int)
     for others in scores.values():
         for addon, score in others.items():
             d[addon] += score
     addons = sorted(d.items(), key=lambda x: x[1], reverse=True)
     return [addon for addon, score in addons if addon not in addon_ids]
開發者ID:abev66,項目名稱:zamboni,代碼行數:9,代碼來源:models.py

示例3: build_recs

 def build_recs(cls, addon_ids):
     """Get the top ranking add-ons according to recommendation scores."""
     scores = AddonRecommendation.scores(addon_ids)
     d = collections.defaultdict(int)
     for others in scores.values():
         for addon, score in others.items():
             d[addon] += score
     addons = [(score, addon) for addon, score in d.items()]
     return [addon for _, addon in sorted(addons)]
開發者ID:ozten,項目名稱:zamboni,代碼行數:9,代碼來源:models.py

示例4: expected_recs

 def expected_recs(self):
     scores, ranked = [], {}
     # Get all the add-on => rank pairs.
     for x in AddonRecommendation.scores(self.ids).values():
         scores.extend(x.items())
     # Sum up any dupes.
     groups = itertools.groupby(sorted(scores), key=lambda x: x[0])
     for addon, pairs in groups:
         ranked[addon] = sum(x[1] for x in pairs)
     addons = sorted(ranked.items(), key=lambda x: x[1], reverse=True)
     return [x[0] for x in addons if x[0] not in self.ids]
開發者ID:rhelmer,項目名稱:zamboni,代碼行數:11,代碼來源:test_models.py


注:本文中的addons.models.AddonRecommendation類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。