From f4115cf102b2aa62e9007af698fa6c496033161a Mon Sep 17 00:00:00 2001 From: liuht Date: Fri, 5 Jan 2024 20:58:53 +0800 Subject: [PATCH] [MNT] add cross feature engineering example --- examples/dataset_table_workflow/base.py | 6 +- examples/dataset_table_workflow/config.py | 97 +++++++++++++++++++-- examples/dataset_table_workflow/hetero.py | 2 +- examples/dataset_table_workflow/workflow.py | 2 +- 4 files changed, 96 insertions(+), 11 deletions(-) diff --git a/examples/dataset_table_workflow/base.py b/examples/dataset_table_workflow/base.py index 169ff9b..5a484bb 100644 --- a/examples/dataset_table_workflow/base.py +++ b/examples/dataset_table_workflow/base.py @@ -149,10 +149,10 @@ class TableWorkflow: # recorder.record(user, idx, scores) # bar.update(1) - process_single_aug(user, idx, all_scores, recorders, save_root_path) + # process_single_aug(user, idx, all_scores, recorders, save_root_path) recorder.save(save_path) - else: - process_single_aug(user, idx, recorder.data[user][idx], recorders, save_root_path) + #else: + process_single_aug(user, idx, recorder.data[user][idx], recorders, save_root_path) else: if test_info["force"] or recorder.should_test_method(user, idx, save_path): scores = self._limited_data(method, test_info, loss_func) diff --git a/examples/dataset_table_workflow/config.py b/examples/dataset_table_workflow/config.py index fd931c4..33c060e 100644 --- a/examples/dataset_table_workflow/config.py +++ b/examples/dataset_table_workflow/config.py @@ -29,8 +29,8 @@ styles = { labels = { 'user_model': "User Model", - 'single_aug': "Single Learnware Reuse (Select)", - "select_score": "Single Learnware Reuse (Select)", + 'single_aug': "Single Learnware Reuse (FeatAug)", + "select_score": "Single Learnware Reuse (FeatAug)", 'multiple_aug': "Multiple Learnware Reuse (FeatAug)", 'ensemble_pruning': "Multiple Learnware Reuse (EnsemblePrune)", 'multiple_avg': "Multiple Learnware Reuse (Averaging)" @@ -95,6 +95,25 @@ user_model_params = { "MAX_ROUNDS": 1000, "early_stopping_rounds": 1000 } + }, + "PFS": { + "lgb": { + "params": { + "boosting_type": "gbdt", + "num_leaves": 2**7 - 1, + "learning_rate": 0.01, + "objective": "rmse", + "metric": "rmse", + "feature_fraction": 0.75, + "bagging_fraction": 0.75, + "bagging_freq": 5, + "seed": 1, + "verbose": -100, + "n_estimators": 100000, + }, + "MAX_ROUNDS": 1000, + "early_stopping_rounds": 1000 + } } } @@ -126,11 +145,77 @@ hetero_cross_feat_eng_benchmark_config = BenchmarkConfig( name="PFS", user_num=41, learnware_ids = [ - + "00000394", "00000393", "00000392", "00000391", + "00000390", "00000389", "00000388", "00000387", + "00000386", "00000385", "00000384", "00000383", + "00000382", "00000381", "00000380", "00000379", + "00000378", "00000377", "00000376", "00000375", + "00000374", "00000373", "00000372", "00000371", + "00000370", "00000369", "00000368", "00000367", + "00000366", "00000365", "00000364", "00000363", + "00000362", "00000361", "00000360", "00000359", + "00000358", "00000357", "00000356", "00000355", + "00000354", "00000353", "00000352", "00000351", + "00000350", "00000349", "00000348", "00000347", + "00000346", "00000345", "00000344", "00000343", + "00000342", "00000444", "00000443", "00000442", + "00000441", "00000440", "00000439", "00000438", + "00000437", "00000436", "00000435", "00000434", + "00000433", "00000432", "00000431", "00000430", + "00000429", "00000428", "00000427", "00000426", + "00000425", "00000424", "00000423", "00000422", + "00000421", "00000420", "00000419", "00000418", + "00000417", "00000416", "00000415", "00000414", + "00000413", "00000412", "00000411", "00000410", + "00000409", "00000408", "00000407", "00000406", + "00000405", "00000404", "00000403", "00000402", + "00000401", "00000400", "00000399", "00000398", + "00000397", "00000396", "00000395", "00000783", + "00000782", "00000781", "00000780", "00000779", + "00000778", "00000777", "00000776", "00000775", + "00000774", "00000773", "00000772", "00000771", + "00000770", "00000769", "00000768", "00000767", + "00000766", "00000765", "00000764", "00000763", + "00000762", "00000761", "00000760", "00000759", + "00000758", "00000757", "00000756", "00000755", + "00000754", "00000753", "00000752", "00000751", + "00000750", "00000749", "00000748", "00000747", + "00000746", "00000745", "00000744", "00000743", + "00000742", "00000741", "00000740", "00000739", + "00000738", "00000737", "00000736", "00000735", + "00000734", "00000733", "00000732", "00000731", + "00000730", "00000839", "00000838", "00000837", + "00000836", "00000835", "00000834", "00000833", + "00000832", "00000831", "00000830", "00000829", + "00000828", "00000827", "00000826", "00000825", + "00000824", "00000823", "00000822", "00000821", + "00000820", "00000819", "00000818", "00000817", + "00000816", "00000815", "00000814", "00000813", + "00000812", "00000811", "00000810", "00000809", + "00000808", "00000807", "00000806", "00000805", + "00000804", "00000803", "00000802", "00000801", + "00000800", "00000799", "00000798", "00000797", + "00000796", "00000795", "00000794", "00000793", + "00000792", "00000791", "00000790", "00000789", + "00000788", "00000787", "00000786", "00000912", + "00000911", "00000910", "00000909", "00000908", + "00000907", "00000906", "00000905", "00000904", + "00000903", "00000902", "00000901", "00000900", + "00000899", "00000898", "00000897", "00000896", + "00000895", "00000894", "00000893", "00000892", + "00000891", "00000890", "00000889", "00000888", + "00000887", "00000886", "00000885", "00000884", + "00000883", "00000882", "00000881", "00000880", + "00000879", "00000878", "00000877", "00000876", + "00000875", "00000874", "00000873", "00000872", + "00000871", "00000870", "00000869", "00000868", + "00000867", "00000866", "00000865", "00000864", + "00000863", "00000862", "00000861", "00000860", + "00000859" ], - test_data_path=None, - train_data_path=None, - extra_info_path=None + test_data_path="PFS/test_data.zip", + train_data_path="PFS/train_data.zip", + extra_info_path="PFS/extra_info.zip" ) hetero_cross_task_benchmark_config = BenchmarkConfig( diff --git a/examples/dataset_table_workflow/hetero.py b/examples/dataset_table_workflow/hetero.py index ca06890..f365971 100644 --- a/examples/dataset_table_workflow/hetero.py +++ b/examples/dataset_table_workflow/hetero.py @@ -158,7 +158,7 @@ class HeterogeneousDatasetWorkflow(TableWorkflow): logger.info(f"Hetero search result of user {user}_{idx}: mixture learnware num: {len(mixture_learnware_list)}") test_info = {"user": user, "idx": idx, "train_subsets": train_subsets, "test_x": test_x, "test_y": test_y, "n_labeled_list": hetero_n_labeled_list} - common_config = {"user_rkme": user_stat_spec, "multiple_learnwares": mixture_learnware_list} + common_config = {"user_rkme": user_stat_spec, "learnwares": mixture_learnware_list} method_configs = { "user_model": {"dataset": self.benchmark.name, "model_type": "lgb"}, "hetero_single_aug": {"user_rkme": user_stat_spec, "learnwares": all_learnwares}, diff --git a/examples/dataset_table_workflow/workflow.py b/examples/dataset_table_workflow/workflow.py index c31420d..902e9fd 100644 --- a/examples/dataset_table_workflow/workflow.py +++ b/examples/dataset_table_workflow/workflow.py @@ -29,7 +29,7 @@ class TableDatasetWorkflow: workflow = HeterogeneousDatasetWorkflow( benchmark_config=hetero_cross_feat_eng_benchmark_config, name="hetero", - rebuild=False + rebuild=True ) workflow.unlabeled_hetero_table_example()