From 1435279c7a4c8d7c967e84c3ceb5e264b5dfd886 Mon Sep 17 00:00:00 2001 From: Xie Yi Date: Sat, 9 Dec 2023 14:58:58 +0800 Subject: [PATCH] [DOC] homo search doc --- docs/workflows/search.rst | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/docs/workflows/search.rst b/docs/workflows/search.rst index d9b48d9..609e534 100644 --- a/docs/workflows/search.rst +++ b/docs/workflows/search.rst @@ -10,7 +10,42 @@ All the searchers are implemented as a subclass of ``BaseSearcher``. When initia Homo Search ====================== -The homogeneous search of helpful learnwares can be divided into two stages: semantic specification search and statistical specification search. Both of them needs ``BaseUserInfo`` as input. +The homogeneous search of helpful learnwares can be divided into two stages: semantic specification search and statistical specification search. Both of them needs ``BaseUserInfo`` as input. The following codes shows how to use the searcher to search for helpful learnwares from a market ``easy_market`` for a user. The introduction of ``EasyMarket`` is in `COMPONENTS: Market <../components/market.html>`_. + +.. code-block:: python + + # generate BaseUserInfo(semantic_spec + stat_info) + user_semantic = { + "Data": {"Values": ["Table"], "Type": "Class"}, + "Task": {"Values": ["Regression"], "Type": "Class"}, + "Library": {"Values": ["Scikit-learn"], "Type": "Class"}, + "Scenario": {"Values": ["Business"], "Type": "Tag"}, + "Description": {"Values": "", "Type": "String"}, + "Name": {"Values": "", "Type": "String"}, + "Input": {"Dimension": 82, "Description": {},}, + "Output": {"Dimension": 1, "Description": {},}, + "License": {"Values": ["MIT"], "Type": "Class"}, + } + user_spec = generate_rkme_table_spec(X=x) + user_info = BaseUserInfo( + semantic_spec=user_semantic, + stat_info={"RKMETableSpecification": user_spec} + ) + + # search the market for the user + search_result = easy_market.search_learnware(user_info) + + # search result: single_result + single_result = search_result.get_single_results() + print(f"single model num: {len(single_result)}, + max_score: {single_result[0].score}, + min_score: {single_result[-1].score}" + ) + + # search result: multiple_result + multiple_result = search_result.get_multiple_results() + mixture_id = " ".join([learnware.id for learnware in multiple_result[0].learnwares]) + print(f"mixture_score: {multiple_result[0].score}, mixture_learnwares: {mixture_id}") Hetero Search