From 108b34c1ffd9a89422ec2d029a2cdee955d49b29 Mon Sep 17 00:00:00 2001 From: bxdd Date: Mon, 24 Apr 2023 13:34:15 +0800 Subject: [PATCH] [MNT] Update setup --- examples/example_image/main.py | 4 +--- examples/example_m5/main.py | 4 +--- examples/example_market_db/example_db.py | 4 +--- examples/example_pfs/main.py | 4 +--- examples/workflow_by_code/main.py | 4 +--- learnware/learnware/reuse.py | 8 +++++--- learnware/market/evolve.py | 2 +- setup.py | 2 +- 8 files changed, 12 insertions(+), 20 deletions(-) diff --git a/examples/example_image/main.py b/examples/example_image/main.py index d20d13f..d8bff9e 100644 --- a/examples/example_image/main.py +++ b/examples/example_image/main.py @@ -153,9 +153,7 @@ def test_search(gamma=0.1, load_market=True): user_data = np.load(user_data_path) user_label = np.load(user_label_path) user_stat_spec = specification.utils.generate_rkme_spec(X=user_data, gamma=gamma, cuda_idx=0) - user_info = BaseUserInfo( - semantic_spec=user_semantic, stat_info={"RKMEStatSpecification": user_stat_spec} - ) + user_info = BaseUserInfo(semantic_spec=user_semantic, stat_info={"RKMEStatSpecification": user_stat_spec}) logger.info("Searching Market for user: %d" % (i)) sorted_score_list, single_learnware_list, mixture_score, mixture_learnware_list = image_market.search_learnware( user_info diff --git a/examples/example_m5/main.py b/examples/example_m5/main.py index a35acb4..3e720ea 100644 --- a/examples/example_m5/main.py +++ b/examples/example_m5/main.py @@ -135,9 +135,7 @@ class M5DatasetWorkflow: user_spec_path = f"./user_spec/user_{idx}.json" user_spec.save(user_spec_path) - user_info = BaseUserInfo( - semantic_spec=user_semantic, stat_info={"RKMEStatSpecification": user_spec} - ) + user_info = BaseUserInfo(semantic_spec=user_semantic, stat_info={"RKMEStatSpecification": user_spec}) ( sorted_score_list, single_learnware_list, diff --git a/examples/example_market_db/example_db.py b/examples/example_market_db/example_db.py index a831279..9d5e934 100644 --- a/examples/example_market_db/example_db.py +++ b/examples/example_market_db/example_db.py @@ -150,9 +150,7 @@ def test_stat_search(): user_spec = specification.rkme.RKMEStatSpecification() user_spec.load(os.path.join(unzip_dir, "svm.json")) - user_info = BaseUserInfo( - semantic_spec=user_senmantic, stat_info={"RKMEStatSpecification": user_spec} - ) + user_info = BaseUserInfo(semantic_spec=user_senmantic, stat_info={"RKMEStatSpecification": user_spec}) sorted_score_list, single_learnware_list, mixture_learnware_list = easy_market.search_learnware(user_info) print(f"search result of user{idx}:") diff --git a/examples/example_pfs/main.py b/examples/example_pfs/main.py index f2915f3..1757156 100644 --- a/examples/example_pfs/main.py +++ b/examples/example_pfs/main.py @@ -133,9 +133,7 @@ class PFSDatasetWorkflow: user_spec_path = f"./user_spec/user_{idx}.json" user_spec.save(user_spec_path) - user_info = BaseUserInfo( - semantic_spec=user_semantic, stat_info={"RKMEStatSpecification": user_spec} - ) + user_info = BaseUserInfo(semantic_spec=user_semantic, stat_info={"RKMEStatSpecification": user_spec}) ( sorted_score_list, single_learnware_list, diff --git a/examples/workflow_by_code/main.py b/examples/workflow_by_code/main.py index 36f3c89..d6a6b75 100644 --- a/examples/workflow_by_code/main.py +++ b/examples/workflow_by_code/main.py @@ -158,9 +158,7 @@ class LearnwareMarketWorkflow: user_spec = specification.rkme.RKMEStatSpecification() user_spec.load(os.path.join(unzip_dir, "svm.json")) - user_info = BaseUserInfo( - semantic_spec=user_semantic, stat_info={"RKMEStatSpecification": user_spec} - ) + user_info = BaseUserInfo(semantic_spec=user_semantic, stat_info={"RKMEStatSpecification": user_spec}) ( sorted_score_list, single_learnware_list, diff --git a/learnware/learnware/reuse.py b/learnware/learnware/reuse.py index ebb9526..d3b0c54 100644 --- a/learnware/learnware/reuse.py +++ b/learnware/learnware/reuse.py @@ -221,13 +221,13 @@ class JobSelectorReuser(BaseReuser): learning_rate = [0.01] max_depth = [66] params = (0, 0) - + lgb_params = { "boosting_type": "gbdt", "n_estimators": 2000, "boost_from_average": False, } - + if num_class == 2: lgb_params["objective"] = "binary" lgb_params["metric"] = "binary_logloss" @@ -252,7 +252,9 @@ class JobSelectorReuser(BaseReuser): lgb_params["learning_rate"] = params[0] lgb_params["max_depth"] = params[1] model = LGBMClassifier(**lgb_params) - model.fit(org_train_x, org_train_y, eval_set=[(org_train_x, org_train_y)], early_stopping_rounds=300, verbose=False) + model.fit( + org_train_x, org_train_y, eval_set=[(org_train_x, org_train_y)], early_stopping_rounds=300, verbose=False + ) return model diff --git a/learnware/market/evolve.py b/learnware/market/evolve.py index 7b24548..8912700 100644 --- a/learnware/market/evolve.py +++ b/learnware/market/evolve.py @@ -39,4 +39,4 @@ class EvolvedMarket(BaseMarket): id_list : List[str] Id list for learnwares """ - pass \ No newline at end of file + pass diff --git a/setup.py b/setup.py index 9807b39..3a6d4a7 100644 --- a/setup.py +++ b/setup.py @@ -51,7 +51,7 @@ def get_platform(): # What packages are required for this module to be executed? # `estimator` may depend on other packages. In order to reduce dependencies, it is not written here. REQUIRED = [ - "numpy>=1.20.0", + "numpy>=1.22.0,<1.24.0", "pandas>=0.25.1", "scipy>=1.0.0", "matplotlib>=3.1.3",