本文整理匯總了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)
示例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]
示例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)]
示例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]