Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 274
Single input task partial fix#541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
a341fcb322b8e9261b7380f8cd8b37f25ab5a1ff476103c02File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -10,9 +10,10 @@ | ||
| from ..datasets import get_dataset | ||
| from .task import ( | ||
| OpenMLClassificationTask, | ||
| OpenMLRegressionTask, | ||
| OpenMLClusteringTask, | ||
| OpenMLLearningCurveTask, | ||
| OpenMLRegressionTask, | ||
| OpenMLSupervisedTask | ||
| ) | ||
| import openml.utils | ||
| import openml._api_calls | ||
| @@ -292,9 +293,13 @@ def get_task(task_id): | ||
| try: | ||
| task = _get_task_description(task_id) | ||
| dataset = get_dataset(task.dataset_id) | ||
| class_labels = dataset.retrieve_class_labels(task.target_name) | ||
| task.class_labels = class_labels | ||
| task.download_split() | ||
| # Clustering tasks do not have class labels | ||
| # and do not offer download_split | ||
| if isinstance(task, OpenMLSupervisedTask): | ||
| task.download_split() | ||
Collaborator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to move this into the task classes? If they have a split and class labels they retrieve them, otherwise, they don't. Also, how does this work for regression tasks (regarding class labels)?
| ||
| if isinstance(task, OpenMLClassificationTask): | ||
| task.class_labels = \ | ||
| dataset.retrieve_class_labels(task.target_name) | ||
| except Exception as e: | ||
| openml.utils._remove_cache_dir_for_id( | ||
| TASKS_CACHE_DIR_NAME, | ||
| @@ -323,6 +328,7 @@ def _get_task_description(task_id): | ||
| fh.write(task_xml) | ||
| return _create_task_from_xml(task_xml) | ||
| def _create_task_from_xml(xml): | ||
| """Create a task given a xml string. | ||
| @@ -336,46 +342,53 @@ def _create_task_from_xml(xml): | ||
| OpenMLTask | ||
| """ | ||
| dic = xmltodict.parse(xml)["oml:task"] | ||
| estimation_parameters = dict() | ||
| inputs = dict() | ||
| # Due to the unordered structure we obtain, we first have to extract | ||
| # the possible keys of oml:input; dic["oml:input"] is a list of | ||
| # OrderedDicts | ||
| for input_ in dic["oml:input"]: | ||
| name = input_["@name"] | ||
| inputs[name] = input_ | ||
| # Check if there is a list of inputs | ||
| if isinstance(dic["oml:input"], list): | ||
| for input_ in dic["oml:input"]: | ||
| name = input_["@name"] | ||
| inputs[name] = input_ | ||
| # Single input case | ||
| elif isinstance(dic["oml:input"], dict): | ||
| name = dic["oml:input"]["@name"] | ||
| inputs[name] = dic["oml:input"] | ||
| evaluation_measures = None | ||
| if 'evaluation_measures' in inputs: | ||
| evaluation_measures = inputs["evaluation_measures"][ | ||
| "oml:evaluation_measures"]["oml:evaluation_measure"] | ||
| # Convert some more parameters | ||
| for parameter in \ | ||
| inputs["estimation_procedure"]["oml:estimation_procedure"][ | ||
| "oml:parameter"]: | ||
| name = parameter["@name"] | ||
| text = parameter.get("#text", "") | ||
| estimation_parameters[name] = text | ||
| task_type = dic["oml:task_type"] | ||
| common_kwargs = { | ||
| 'task_id': dic["oml:task_id"], | ||
| 'task_type': task_type, | ||
| 'task_type_id': dic["oml:task_type_id"], | ||
| 'data_set_id': inputs["source_data"][ | ||
| "oml:data_set"]["oml:data_set_id"], | ||
| 'estimation_procedure_type': inputs["estimation_procedure"][ | ||
| "oml:estimation_procedure"]["oml:type"], | ||
| 'estimation_parameters': estimation_parameters, | ||
| 'evaluation_measure': evaluation_measures, | ||
| } | ||
| if task_type in ( | ||
| "Supervised Classification", | ||
| "Supervised Regression", | ||
| "Learning Curve" | ||
| ): | ||
| # Convert some more parameters | ||
| for parameter in \ | ||
| inputs["estimation_procedure"]["oml:estimation_procedure"][ | ||
| "oml:parameter"]: | ||
| name = parameter["@name"] | ||
| text = parameter.get("#text", "") | ||
| estimation_parameters[name] = text | ||
| common_kwargs['estimation_procedure_type'] = inputs[ | ||
| "estimation_procedure"][ | ||
| "oml:estimation_procedure"]["oml:type"], | ||
| common_kwargs['estimation_parameters'] = estimation_parameters, | ||
| common_kwargs['target_name'] = inputs[ | ||
| "source_data"]["oml:data_set"]["oml:target_feature"] | ||
| common_kwargs['data_splits_url'] = inputs["estimation_procedure"][ | ||
Uh oh!
There was an error while loading. Please reload this page.