def other_trends(self, movie): #This function works very similarly to the above functions, such as director_trends. #See the above functions for additional details. source = movie[3][1] creative = movie[3][2] method = movie[3][3] budget = movie[1][1] date = movie[4][3] year = movie[4][0] films = [] nfilms = [] total = [] for entry in self.data2: if source==entry[3][1] and creative==entry[3][2] and method==entry[3][3] and entry[4][3]<date and entry[4][0]>year-10: films.append(entry) if len(films)==0: return None nfilms = utilities.closest_matches(films, budget) for item in nfilms: total.append(item[1][2]) count = Counter(total) final = count.most_common()[0][0] return final
def genre_trends(self, movie): #This function works very similarly to the above functions, such as director_trends. #See the above functions for additional details. genre = movie[3][0] b = movie[1][1] date = movie[4][3] year = movie[4][0] gross = 0 budget = 0 films = [] nfilms = [] total = [] for entry in self.data2: if genre==entry[3][0] and entry[4][3]<date and entry[4][0]>year-10: films.append(entry) if len(films)==0: return None nfilms = utilities.closest_matches(films, b) for item in nfilms: gross+= item[1][0] budget+= item[1][1] total.append(item[1][2]) av_gross = float(gross)/float(budget) count = Counter(total) final = count.most_common()[0][0] return [final, av_gross]
def director_trends(self, movie): #This function works very similarly to 'weekrate'. See that function for #further details if necessary. date = movie[4][3] year = movie[4][0] b = movie[1][1] #budget director = movie[2][4] gross = 0 budget = 0 films = [] nfilms = [] total = [] blockbuster = None #stores recent blockbuster film made by director for entry in self.data2: #if a film in the data was directed by the given director, but was #released prior to the current film within the previous 15 years if director==entry[2][4] and entry[4][3]<date and entry[4][0]>year-15: films.append(entry) if len(films)==0: return None films.sort(key = lambda x: x[4][3]) recent = films[-1] for item in films: #if one of the films grossed more than $300,000,000 if item[1][0]>300000000: #it is the 'blockbuster'. Since the list is already sorted, if #there are multiple, then the most recent takes the value of #'blockbuster'. blockbuster = item nfilms = utilities.closest_matches(films, b) for item in nfilms: gross+= item[1][0] budget+= item[1][1] total.append(item[1][2]) av_gross = float(gross)/float(budget) count = Counter(total) final = count.most_common()[0][0] return [final, av_gross, recent, blockbuster]
def weekrate(self, n, b): gross = 0 #Running total of the domestic gross of all films released #on the specified week of the year. budget = 0 #Running total of the budget " " films = [] #List of all films released on the specified week of the year. nfilms = [] #Narrowed list of matching films, based on similar budgets. total = [] #List of revenue tiers for films released on specified week. for movie in self.data2: #find the week of the movie's release date = utilities.findweek(movie[4][0], movie[4][1], movie[4][2]) if date==n: #if the release week's match films.append(movie) #list the movie #if no matches were found, return None if len(films)==0: return None #otherwise narrow the results to include only those with the most #similar budgets nfilms = utilities.closest_matches(films, b) #then go through the list for entry in nfilms: gross+= entry[1][0] #sum the revenues budget+= entry[1][1] #sum the budgets total.append(entry[1][2]) #list the revenue tiers #determine the average success ratio av_gross = float(gross)/float(budget) #The final value of the revenue tier projection is the most common #value listed. In other words, if most films fall in tier 3, then #final = 3. count = Counter(total) final = count.most_common()[0][0] #return an array of results return [final, av_gross]
def actor_trends(self, actor, movie): date = movie[4][3] year = movie[4][0] b = movie[1][1] #budget of searched film gross = 0 #Running total of the domestic gross of all films released #on the specified week of the year. budget = 0 #Running total of the budget " " films = [] #List of all films released on the specified week of the year. nfilms = [] #Narrowed list of matching films, based on similar budgets. total = [] #List of revenue tiers for films released on specified week. apartnerships = [] #list of actor partnerships dpartnerships = [] #list of director partnerships recent = None #most recent film released for entry in self.data2: #for each film in the data, if the actor is one of the main actors #in the film, but the film was released before the current movie #and was released in the last 5 years, and is not an animated film if actor in entry[2][1] and entry[4][3]<date and entry[4][0]>year-5 and entry[3][3]!="Digital Animation": films.append(entry) #add it to the list #if no matches were found, return None if len(films)==0: return None #sort the films according to when they were released films.sort(key = lambda x: x[4][3]) #the last one released becomes 'recent' recent = films[-1] for f in films: #if the actor has worked with another actor in the current movie before #and successful films were produced together, then... for a in f[2][1]: if a!=actor and movie[2][2]!=f[2][2] and a in movie[2][1] and f[1][0]>100000000: apartnerships.append([a, f]) #... add it to the list #similarly, if the actor has worked with the same director on a previous #film and it was successful, then... if movie[2][4]==f[2][4] and f[1][0]>100000000: dpartnerships.append([movie[2][4], f]) #... add it to the list #narrow the list of matches according to most similar budgets nfilms = utilities.closest_matches(films, b) #then go through the list for item in nfilms: gross+= item[1][0] #sum the revenues budget+= item[1][1] #sum the budgets total.append(item[1][2]) #list the revenue tiers #determine the average success ratio av_gross = float(gross)/float(budget) #The final value of the revenue tier projection is the most common #value listed. In other words, if most films fall in tier 3, then #final = 3. count = Counter(total) final = count.most_common()[0][0] #return an array of results return [final, av_gross, recent, apartnerships, dpartnerships]