def main(filename): """ pipeline for representation learning for all papers for a given name reference """ latent_dimen = 40 alpha = 0.1 matrix_reg = 0.1 num_epoch = 2 sampler_method = 'uniform' dataset = parser.DataSet(filename) dataset.reader_arnetminer() bpr_optimizer = embedding.BprOptimizer(latent_dimen, alpha, matrix_reg) # pp_sampler = sampler.CoauthorGraphSampler() # pd_sampler = sampler.BipartiteGraphSampler() dd_sampler = sampler.LinkedDocGraphSampler() dt_sampler = sampler.DocumentTitleSampler() djconf_sampler = sampler.DocumentJConfSampler() dyear_sampler = sampler.DocumentYearSampler() dorg_sampler = sampler.DocumentOrgSampler() dabstract_sampler = sampler.DocumentAbstractSampler() eval_f1 = eval_metric.Evaluator() run_helper = train_helper.TrainHelper() # avg_f1 = run_helper.helper(num_epoch, dataset, bpr_optimizer, # pp_sampler, pd_sampler, dd_sampler, # dt_sampler,djconf_sampler, # eval_f1, sampler_method) # 基本的,不加任何额外的东西 avg_f1, avg_pre, avg_rec = run_helper.helper( num_epoch, dataset, bpr_optimizer, # pp_sampler, # pd_sampler, dd_sampler, dt_sampler, # djconf_sampler, # dorg_sampler, # dyear_sampler, dabstract_sampler, eval_f1, sampler_method, filename) F1_Max_List.append(avg_f1) F1_Max_List_pre.append(avg_pre) F1_Max_List_rec.append(avg_rec) print avg_f1
def main(args): """ pipeline for representation learning for all papers for a given name reference """ dataset = data_parser.DataSet(args.file_path) bpr_optimizer = embedding.BprOptimizer(args.latent_dimen, args.alpha, args.matrix_reg) pp_sampler = sampler.CoauthorGraphSampler() pd_sampler = sampler.BipartiteGraphSampler() dd_sampler = sampler.LinkedDocGraphSampler() eval_f1 = eval_metric.Evaluator() run_helper = train_helper.TrainHelper() return run_helper.helper(args.num_epoch, dataset, bpr_optimizer, pp_sampler, pd_sampler, dd_sampler, eval_f1, args.sampler_method)
def main(file_path, latent_dimen, alpha, matrix_reg, num_epoch, sampler_method): """ pipeline for representation learning for all papers for a given name reference """ dataset = parser_helper.DataSet(file_path) paper_count = dataset.reader() bpr_optimizer = embedding.BprOptimizer(latent_dimen, alpha, matrix_reg) pp_sampler = sampler.CoauthorGraphSampler() pd_sampler = sampler.BipartiteGraphSampler() dd_sampler = sampler.LinkedDocGraphSampler() eval_f1 = eval_metric.Evaluator() run_helper = train_helper.TrainHelper() pairwise_precision, pairwise_recall, pairwise_f1 = run_helper.helper( num_epoch, dataset, bpr_optimizer, pp_sampler, pd_sampler, dd_sampler, eval_f1, sampler_method) return paper_count, pairwise_precision, pairwise_recall, pairwise_f1