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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started