def retriveResponse(year=DEFAULT_YearDivide,is_training=True): """ Given the year dividing training and test sets, return the list of all movies and the SuccessMetric """ if is_training: comp_symbol = '<' else: comp_symbol = '>' statement1 = 'select title,released,ifnull(totalgross,0),'+\ 'ifnull(budget,0)'+\ ' from boxoffice where boxoffice.released'+\ ' %s \"%s\" order by released asc;' % (comp_symbol,year) results = mysqlfuncs.db_execute_and_fetch(statement1) title = mysqlfuncs.results_to_list(results,index=0) released = mysqlfuncs.results_to_list(results,index=1) releaseYears = [long(misc.getYear(x.strftime("%Y-%m-%d"))) for x in released] totalGross = num.array(mysqlfuncs.results_to_list(results,index=2),\ dtype=float) budget = num.array(mysqlfuncs.results_to_list(results,index=3),dtype=float) SuccessMetric = misc.returnSuccessMetric(totalGross,budget) return releaseYears,title,SuccessMetric,budget,totalGross
def get_successMetric_history(person): """ get the successMetric and release dates and titles for a given person (also called `part` in moive_meta) """ # setup the query statement1 = 'select title,released,ifnull(totalgross,0),ifnull(budget,0)' statement1 += ' from boxoffice where boxoffice.title = any ' statement1 += '(select `title` from movie_meta ' statement1 += 'where(part = "%s")) order by released asc;' % (person) # get the title, release data, total gross and budget results = db_execute_and_fetch(statement1) title = results_to_list(results,index=0) release = results_to_list(results,index=1) totalGross = num.array(results_to_list(results,index=2),dtype=float) budget = num.array(results_to_list(results,index=3),dtype=float) # compute the sucess metric = log10(totalGross/budget) successMetric = misc.returnSuccessMetric(totalGross,budget) return release,successMetric,title,budget,totalGross