Question: Hello can anyone help me with a code by importing MRStep you have to create more than one mapper and one reducer and find out:

Hello can anyone help me with a code by importing MRStep you have to create more than one mapper and one reducer and find out:

a) Sum of all ratings that the movie ids got b) Max no of ratings that a specific ID got. Hint. For max ratings use Python max() function

from mrjob.job import MRJob from mrjob.step import MRStep import re RATING_REGEXP = re.compile(r"[\w']+") class MRFR(MRJob): def steps(self): return [ MRStep(mapper=self.mapper_get_movieID, reducer=self.reducer_count_rating), MRStep(mapper=self.mapper_make_counts_key, reducer = self.reducer_output_rating) ] def mapper_get_movieID(self, _, line): RATE = RATING_REGEXP.findall(line) for movieID in movieID: yield movieID(), 1 def reducer_count_rating(self, rating, values): # yield rating, sum(values) def mapper_make_counts_key(self, rating, count): yield '%04d'%int(count), rating def reducer_output_rating(self, count, rating): for rating in rating: yield count, rating if __name__ == '__main__': MRFR.run()

This is what i got so far. please help

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!