diff --git a/examples/example_market_db/example_db.py b/examples/example_market_db/example_db.py index 32aeb07..1cb1425 100644 --- a/examples/example_market_db/example_db.py +++ b/examples/example_market_db/example_db.py @@ -14,10 +14,7 @@ curr_root = os.path.dirname(os.path.abspath(__file__)) semantic_specs = [ { "Data": {"Values": ["Tabular"], "Type": "Class"}, - "Task": { - "Values": ["Classification"], - "Type": "Class", - }, + "Task": {"Values": ["Classification"], "Type": "Class"}, "Device": {"Values": ["GPU"], "Type": "Tag"}, "Scenario": {"Values": ["Nature"], "Type": "Tag"}, "Description": {"Values": "", "Type": "Description"}, @@ -25,10 +22,7 @@ semantic_specs = [ }, { "Data": {"Values": ["Tabular"], "Type": "Class"}, - "Task": { - "Values": ["Classification"], - "Type": "Class", - }, + "Task": {"Values": ["Classification"], "Type": "Class"}, "Device": {"Values": ["GPU"], "Type": "Tag"}, "Scenario": {"Values": ["Business", "Nature"], "Type": "Tag"}, "Description": {"Values": "", "Type": "Description"}, @@ -36,10 +30,7 @@ semantic_specs = [ }, { "Data": {"Values": ["Tabular"], "Type": "Class"}, - "Task": { - "Values": ["Classification"], - "Type": "Class", - }, + "Task": {"Values": ["Regression"], "Type": "Class"}, "Device": {"Values": ["GPU"], "Type": "Tag"}, "Scenario": {"Values": ["Business"], "Type": "Tag"}, "Description": {"Values": "", "Type": "Description"}, @@ -49,10 +40,7 @@ semantic_specs = [ user_senmantic = { "Data": {"Values": ["Tabular"], "Type": "Class"}, - "Task": { - "Values": ["Classification"], - "Type": "Class", - }, + "Task": {"Values": ["Classification"], "Type": "Class",}, "Device": {"Values": ["GPU"], "Type": "Tag"}, "Scenario": {"Values": ["Business"], "Type": "Tag"}, "Description": {"Values": "", "Type": "Description"}, @@ -129,15 +117,20 @@ def test_search_semantics(): test_folder = "./test_stat" zip_path_list = get_zip_path_list() - for idx, zip_path in enumerate(zip_path_list): - unzip_dir = os.path.join(test_folder, f"{idx}") - os.makedirs(unzip_dir, exist_ok=True) - os.system(f"unzip -o -q {zip_path} -d {unzip_dir}") - - user_spec = specification.rkme.RKMEStatSpecification() - user_spec.load(os.path.join(unzip_dir, "svm.json")) - user_info = BaseUserInfo(id="user_0", semantic_spec=user_senmantic, stat_info={"RKME": user_spec}) - sorted_dist_list, single_learnware_list, mixture_learnware_list = easy_market.search_learnware(user_info) + idx, zip_path = 1, zip_path_list[1] + unzip_dir = os.path.join(test_folder, f"{idx}") + os.makedirs(unzip_dir, exist_ok=True) + os.system(f"unzip -o -q {zip_path} -d {unzip_dir}") + + user_spec = specification.rkme.RKMEStatSpecification() + user_spec.load(os.path.join(unzip_dir, "svm.json")) + user_info = BaseUserInfo(id="user_0", semantic_spec=user_senmantic) + _, single_learnware_list, _ = easy_market.search_learnware(user_info) + + print("User info:", user_info.get_semantic_spec()) + print(f"search result of user{idx}:") + for learnware in single_learnware_list: + print("Choose learnware:", learnware.id, learnware.get_specification().get_semantic_spec()) os.system(f"rm -r {test_folder}") @@ -174,5 +167,5 @@ if __name__ == "__main__": learnware_num = 10 prepare_learnware(learnware_num) test_market() - test_stat_search() + # test_stat_search() test_search_semantics()