当前位置: 首页>>代码示例>>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;未经允许,请勿转载。