From 45fdcd7a4e0e50629d720d18cedad69c5c18c956 Mon Sep 17 00:00:00 2001 From: liuht Date: Sat, 22 Apr 2023 00:20:13 +0800 Subject: [PATCH] [MNT] basic version of learnware market workflow --- docs/introduction/quick.rst | 43 ++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/docs/introduction/quick.rst b/docs/introduction/quick.rst index 99b6e11..9876538 100644 --- a/docs/introduction/quick.rst +++ b/docs/introduction/quick.rst @@ -109,19 +109,46 @@ Users can start an Learnware Market workflow according to the following steps: "Task": { "Values": ["Classification"], "Type": "Class", - }, - "Device": {"Values": ["GPU"], "Type": "Tag"}, - "Scenario": {"Values": ["Business"], "Type": "Tag"}, - "Description": {"Values": "", "Type": "String"}, - "Name": {"Values": "", "Type": "String"}, - } - user_info = BaseUserInfo(id="user_0", semantic_spec=user_semantic) - _, single_learnware_list, _ = easy_market.search_learnware(user_info) + }, + "Device": {"Values": ["GPU"], "Type": "Tag"}, + "Scenario": {"Values": ["Business"], "Type": "Tag"}, + "Description": {"Values": "", "Type": "String"}, + "Name": {"Values": "", "Type": "String"}, + } + user_info = BaseUserInfo(id="user", semantic_spec=user_semantic) + _, single_learnware_list, _ = easy_market.search_learnware(user_info) 4. Statistical specification search: + Here, ``unzip_path`` is the directory where you unzip your learnware file, and ``rkme.json`` is your learnware's + statistical specification. + + .. code-block:: python + + import learnware.specification as specification + + user_spec = specification.rkme.RKMEStatSpecification() + user_spec.load(os.path.join(unzip_path, "rkme.json")) + user_info = BaseUserInfo( + id="user", semantic_spec=user_semantic, stat_info={"RKMEStatSpecification": user_spec} + ) + (sorted_score_list, single_learnware_list, + mixture_score, mixture_learnware_list) = easy_market.search_learnware(user_info) + 5. Reuse learnwares: + Based on the returned list of learnwares ``mixture_learnware_list`` in the previous step, + you can easily reuse them to make predictions your own data, instead of training a model from scratch. + We provide two baseline methods for reusing a given list of learnwares, namely ``JobSelectorReuser`` and ``AveragingReuser``. + + .. code-block:: python + + reuse_job_selector = JobSelectorReuser(learnware_list=mixture_learnware_list) + job_selector_predict_y = reuse_job_selector.predict(user_data=test_x) + + reuse_ensemble = AveragingReuser(learnware_list=mixture_learnware_list, mode='vote') + ensemble_predict_y = reuse_ensemble.predict(user_data=test_x) + .. _script: Example: Learnware Files