openml-python
openml-python copied to clipboard
Improve error message when assigning an invalid estimation procedure to a new task
Creating a new task with a wrong estimation procedure gives an error message which tells you what the issue is, but little information on what the right value could be:
>>> t = openml.tasks.create_task(openml.tasks.task.TaskType.SUPERVISED_REGRESSION, 42728, 1, target_name='DepDelay', evaluation_measure='mean_absolute_error')
>>> t.publish()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "E:\repositories\openml-python\openml\base.py", line 130, in publish
response_text = openml._api_calls._perform_api_call(
File "E:\repositories\openml-python\openml\_api_calls.py", line 65, in _perform_api_call
response = _read_url_files(url, data=data, file_elements=file_elements)
File "E:\repositories\openml-python\openml\_api_calls.py", line 197, in _read_url_files
response = _send_request(request_method="post", url=url, data=data, files=file_elements,)
File "E:\repositories\openml-python\openml\_api_calls.py", line 237, in _send_request
__check_response(response=response, url=url, file_elements=files)
File "E:\repositories\openml-python\openml\_api_calls.py", line 284, in __check_response
raise __parse_server_exception(response, url, file_elements=file_elements)
openml.exceptions.OpenMLServerException: https://www.openml.org/api/v1/xml/task/ returned code 622: Input value does not match allowed values in foreign column. - problematic input: [estimation_procedure], acceptable inputs: [7, 8, 9, 10, 11, 12, 24, 27]
I suggest we match up the acceptable inputs with the full list openml.tasks.functions._get_estimation_procedure_list() (e.g. 7: 10-fold Crossvalidation, 8: 5 times 2-fold Crossvalidation etc.). We can also probably catch this error before even sending it to the server, by cross-referencing the task_type in the create_task call with the one that's specified in the estimation_procedure_list.
Related to #1078