|
6 | 6 | import pandas as pd |
7 | 7 | import xmltodict |
8 | 8 |
|
9 | | -import openml |
| 9 | +from openml.tasks.functions import _get_estimation_procedure_list |
10 | 10 | from openml.tasks.task import ( |
11 | 11 | OpenMLClassificationTask, |
12 | 12 | OpenMLClusteringTask, |
|
19 | 19 | from .base import ResourceV1API, ResourceV2API, TaskAPI |
20 | 20 |
|
21 | 21 |
|
22 | | -def _get_estimation_procedure_list() -> list[dict[str, Any]]: |
23 | | - """Return a list of all estimation procedures which are on OpenML. |
24 | | -
|
25 | | - Returns |
26 | | - ------- |
27 | | - procedures : list |
28 | | - A list of all estimation procedures. Every procedure is represented by |
29 | | - a dictionary containing the following information: id, task type id, |
30 | | - name, type, repeats, folds, stratified. |
31 | | - """ |
32 | | - url_suffix = "estimationprocedure/list" |
33 | | - xml_string = openml._api_calls._perform_api_call(url_suffix, "get") |
34 | | - |
35 | | - procs_dict = xmltodict.parse(xml_string) |
36 | | - # Minimalistic check if the XML is useful |
37 | | - if "oml:estimationprocedures" not in procs_dict: |
38 | | - raise ValueError("Error in return XML, does not contain tag oml:estimationprocedures.") |
39 | | - |
40 | | - if "@xmlns:oml" not in procs_dict["oml:estimationprocedures"]: |
41 | | - raise ValueError( |
42 | | - "Error in return XML, does not contain tag " |
43 | | - "@xmlns:oml as a child of oml:estimationprocedures.", |
44 | | - ) |
45 | | - |
46 | | - if procs_dict["oml:estimationprocedures"]["@xmlns:oml"] != "http://openml.org/openml": |
47 | | - raise ValueError( |
48 | | - "Error in return XML, value of " |
49 | | - "oml:estimationprocedures/@xmlns:oml is not " |
50 | | - "http://openml.org/openml, but {}".format( |
51 | | - str(procs_dict["oml:estimationprocedures"]["@xmlns:oml"]) |
52 | | - ), |
53 | | - ) |
54 | | - |
55 | | - procs: list[dict[str, Any]] = [] |
56 | | - for proc_ in procs_dict["oml:estimationprocedures"]["oml:estimationprocedure"]: |
57 | | - task_type_int = int(proc_["oml:ttid"]) |
58 | | - try: |
59 | | - task_type_id = TaskType(task_type_int) |
60 | | - procs.append( |
61 | | - { |
62 | | - "id": int(proc_["oml:id"]), |
63 | | - "task_type_id": task_type_id, |
64 | | - "name": proc_["oml:name"], |
65 | | - "type": proc_["oml:type"], |
66 | | - }, |
67 | | - ) |
68 | | - except ValueError as e: |
69 | | - warnings.warn( |
70 | | - f"Could not create task type id for {task_type_int} due to error {e}", |
71 | | - RuntimeWarning, |
72 | | - stacklevel=2, |
73 | | - ) |
74 | | - |
75 | | - return procs |
76 | | - |
77 | | - |
78 | 22 | def _create_task_from_xml(xml: str) -> OpenMLTask: |
79 | 23 | """Create a task given a xml string. |
80 | 24 |
|
|
0 commit comments