From f5b1839f9cb686735310f7f9e8623c88ff580bae Mon Sep 17 00:00:00 2001 From: Lennart Purucker Date: Mon, 14 Apr 2025 10:56:20 +0200 Subject: [PATCH 1/3] fix: tasks from sever use default estimation procedure ID --- openml/tasks/functions.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openml/tasks/functions.py b/openml/tasks/functions.py index 00a8e822d..226eef1a4 100644 --- a/openml/tasks/functions.py +++ b/openml/tasks/functions.py @@ -478,6 +478,7 @@ def _create_task_from_xml(xml): "data_set_id": inputs["source_data"]["oml:data_set"]["oml:data_set_id"], "evaluation_measure": evaluation_measures, } + # TODO: add OpenMLClusteringTask? if task_type in ( TaskType.SUPERVISED_CLASSIFICATION, TaskType.SUPERVISED_REGRESSION, @@ -494,6 +495,10 @@ def _create_task_from_xml(xml): common_kwargs["estimation_procedure_type"] = inputs["estimation_procedure"][ "oml:estimation_procedure" ]["oml:type"] + common_kwargs["estimation_procedure_id"] = int(inputs["estimation_procedure"][ + "oml:estimation_procedure" + ]["oml:id"]) + 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"][ From ca8def0c9b4ef23c78e970bb818aa12c68dd6e53 Mon Sep 17 00:00:00 2001 From: LennartPurucker Date: Tue, 17 Jun 2025 16:58:09 +0200 Subject: [PATCH 2/3] add: change tests to actually check the ID --- tests/test_tasks/test_classification_task.py | 5 +++-- tests/test_tasks/test_regression_task.py | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/test_tasks/test_classification_task.py b/tests/test_tasks/test_classification_task.py index bb4545154..d3553262f 100644 --- a/tests/test_tasks/test_classification_task.py +++ b/tests/test_tasks/test_classification_task.py @@ -15,7 +15,7 @@ def setUp(self, n_levels: int = 1): super().setUp() self.task_id = 119 # diabetes self.task_type = TaskType.SUPERVISED_CLASSIFICATION - self.estimation_procedure = 1 + self.estimation_procedure = 5 def test_get_X_and_Y(self): X, Y = super().test_get_X_and_Y() @@ -30,7 +30,8 @@ def test_download_task(self): assert task.task_id == self.task_id assert task.task_type_id == TaskType.SUPERVISED_CLASSIFICATION assert task.dataset_id == 20 + assert task.estimation_procedure_id == self.estimation_procedure def test_class_labels(self): task = get_task(self.task_id) - assert task.class_labels == ["tested_negative", "tested_positive"] + assert task.class_labels == ["tested_negative", "tested_positive"] \ No newline at end of file diff --git a/tests/test_tasks/test_regression_task.py b/tests/test_tasks/test_regression_task.py index 36decc534..14ed59470 100644 --- a/tests/test_tasks/test_regression_task.py +++ b/tests/test_tasks/test_regression_task.py @@ -18,11 +18,11 @@ class OpenMLRegressionTaskTest(OpenMLSupervisedTaskTest): def setUp(self, n_levels: int = 1): super().setUp() - + self.estimation_procedure = 9 task_meta_data = { "task_type": TaskType.SUPERVISED_REGRESSION, "dataset_id": 105, # wisconsin - "estimation_procedure_id": 7, + "estimation_procedure_id": self.estimation_procedure, # non default value to test estimation procedure id "target_name": "time", } _task_id = check_task_existence(**task_meta_data) @@ -46,7 +46,7 @@ def setUp(self, n_levels: int = 1): raise Exception(repr(e)) self.task_id = task_id self.task_type = TaskType.SUPERVISED_REGRESSION - self.estimation_procedure = 7 + def test_get_X_and_Y(self): X, Y = super().test_get_X_and_Y() @@ -61,3 +61,4 @@ def test_download_task(self): assert task.task_id == self.task_id assert task.task_type_id == TaskType.SUPERVISED_REGRESSION assert task.dataset_id == 105 + assert task.estimation_procedure_id == self.estimation_procedure From c8e8371f4b6b21322e7e70d73ea8acd0dd31f9f3 Mon Sep 17 00:00:00 2001 From: LennartPurucker Date: Tue, 17 Jun 2025 17:23:21 +0200 Subject: [PATCH 3/3] fix: linting --- openml/tasks/functions.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openml/tasks/functions.py b/openml/tasks/functions.py index f8766fb67..c4bb13617 100644 --- a/openml/tasks/functions.py +++ b/openml/tasks/functions.py @@ -509,9 +509,9 @@ def _create_task_from_xml(xml: str) -> OpenMLTask: common_kwargs["estimation_procedure_type"] = inputs["estimation_procedure"][ "oml:estimation_procedure" ]["oml:type"] - common_kwargs["estimation_procedure_id"] = int(inputs["estimation_procedure"][ - "oml:estimation_procedure" - ]["oml:id"]) + common_kwargs["estimation_procedure_id"] = int( + inputs["estimation_procedure"]["oml:estimation_procedure"]["oml:id"] + ) common_kwargs["estimation_parameters"] = estimation_parameters common_kwargs["target_name"] = inputs["source_data"]["oml:data_set"]["oml:target_feature"]