I am new to python and trying to build a recommendation system following the instruction http://www.yekeren.com/blog/archives/1005,
what confuses me is that :
def reducer3_init(self):
self.pop = { }
file = open(self.options.item_pop, "r")
for line in file.readlines():
movieid_jstr, pop_jstr = line.strip().split("\t")
movieid = json.loads(movieid_jstr)
pop = json.loads(pop_jstr)
self.pop[movieid] = pop
file.close()
def reducer3(self, key, values):
yield key, sum(values) / math.sqrt(self.pop[key[0]] * self.pop[key[1]])
The reduce3
has no corresponding mapper
,how does it execute ? and what does json.load() do?
A Lot Thanks!!