Skip to content

Commit

Permalink
Merge pull request apachecn#520 from cclauss/patch-1
Browse files Browse the repository at this point in the history
Simplify ret creation with dict comprehension
  • Loading branch information
jiangzhonglian authored May 22, 2019
2 parents 327f48d + cbdde1f commit ded207f
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/py3.x/16.RecommenderSystems/test_lfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

# 负样本采样过程
def RandomSelectNegativeSample(self, items):
ret = dict()
for i in items.keys():
ret[i] = 1

ret = {key: 1 for key in items}
n = 0
for i in range(0, len(items) * 3):
item = items_pool[random.randint(0, len(items_pool) - 1)]
Expand Down

0 comments on commit ded207f

Please sign in to comment.