def performance(algo_name, database, libs=['buffalo', 'implicit', 'lightfm', 'qmf', 'pyspark'], gpu=False): assert database in [ 'ml100k', 'ml20m', 'kakao_reco_730m', 'kakao_brunch_12m' ] assert algo_name in ['als', 'bpr'] if isinstance(libs, str): libs = [libs] if gpu: assert algo_name == 'als' libs = [l for l in libs if l in ['buffalo', 'implicit']] if algo_name == 'als': libs = [l for l in libs if l not in ['lightfm']] elif algo_name == 'bpr': libs = [l for l in libs if l not in ['pyspark']] R = { 'buffalo': BuffaloLib, 'implicit': ImplicitLib, 'lightfm': LightfmLib, 'qmf': QmfLib, 'pyspark': PysparkLib } results = {l: _performance(algo_name, database, R[l](), gpu) for l in libs} _print_table(results)
def compare_warp_bpr(database): assert database in [ 'kakao_reco_730m', 'ml20m', 'ml100k', 'kakao_brunch_12m' ] rets = {} rets['bprmf'] = _buffalo_validation('bpr', database) rets['warp'] = _buffalo_validation('warp', database) _print_table(rets)
def memory(algo_name, database, libs=['buffalo', 'implicit'], gpu=False): assert database in ['ml100k', 'ml20m', 'kakao_reco_730m', 'kakao_brunch_12m'] assert algo_name in ['als', 'bpr'] if isinstance(libs, str): libs = [libs] R = {'buffalo': BuffaloLib, 'implicit': ImplicitLib} results = {l: _memory(algo_name, database, R[l](), gpu) for l in libs} _print_table(results)
def accuracy(algo_name, database, libs=['lightfm']): assert algo_name in ['als', 'bpr', 'warp'] assert database in [ 'kakao_reco_730m', 'ml20m', 'ml100k', 'kakao_brunch_12m' ] L = {'buffalo': BuffaloLib, 'lightfm': LightfmLib} rets = {} for lib in libs: rets[lib] = _get_validation_score(algo_name, L[lib](), database) _print_table(rets)
def buffalo(algo_name='als', database='kakao_brunch_12m'): assert database in ['ml100k', 'ml20m', 'kakao_reco_730m', 'kakao_brunch_12m'] assert algo_name in ['als', 'bpr'] results = _buffalo(algo_name, database) _print_table(results)