Skip to content
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

Add username #790

Merged
merged 11 commits into from
Oct 1, 2019
1 change: 1 addition & 0 deletions doc/progress.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Changelog
* ADD #412: The scikit-learn extension populates the short name field for flows.
* MAINT #726: Update examples to remove deprecation warnings from scikit-learn
* MAINT #752: Update OpenML-Python to be compatible with sklearn 0.21
* ADD #790: Add user ID and name to list_evaluations


0.9.0
Expand Down
9 changes: 8 additions & 1 deletion openml/evaluations/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class OpenMLEvaluation(object):
The evaluation metric of this item (e.g., accuracy).
upload_time : str
The time of evaluation.
uploader: int
Uploader ID (user ID)
upload_name : str
Name of the uploader of this evaluation
value : float
The value (score) of this evaluation.
values : List[float]
Expand All @@ -35,7 +39,8 @@ class OpenMLEvaluation(object):
(e.g., in case of precision, auroc, recall)
"""
def __init__(self, run_id, task_id, setup_id, flow_id, flow_name,
data_id, data_name, function, upload_time, value, values,
data_id, data_name, function, upload_time, uploader: int,
uploader_name: str, value, values,
array_data=None):
self.run_id = run_id
self.task_id = task_id
Expand All @@ -46,6 +51,8 @@ def __init__(self, run_id, task_id, setup_id, flow_id, flow_name,
self.data_name = data_name
self.function = function
self.upload_time = upload_time
self.uploader = uploader
self.uploader_name = uploader_name
self.value = value
self.values = values
self.array_data = array_data
Expand Down
10 changes: 10 additions & 0 deletions openml/evaluations/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ def __list_evaluations(api_call, output_format='object'):
type(evals_dict['oml:evaluations'])

evals = collections.OrderedDict()
uploader_ids = list(set([eval_['oml:uploader'] for eval_ in
evals_dict['oml:evaluations']['oml:evaluation']]))
api_users = "user/list/user_id/" + ','.join(uploader_ids)
xml_string_user = openml._api_calls._perform_api_call(api_users, 'get')
users = xmltodict.parse(xml_string_user, force_list=('oml:user',))
user_dict = {user['oml:id']: user['oml:username'] for user in users['oml:users']['oml:user']}
for eval_ in evals_dict['oml:evaluations']['oml:evaluation']:
run_id = int(eval_['oml:run_id'])
value = None
Expand All @@ -194,6 +200,8 @@ def __list_evaluations(api_call, output_format='object'):
eval_['oml:data_name'],
eval_['oml:function'],
eval_['oml:upload_time'],
int(eval_['oml:uploader']),
user_dict[eval_['oml:uploader']],
value, values, array_data)
else:
# for output_format in ['dict', 'dataframe']
Expand All @@ -206,6 +214,8 @@ def __list_evaluations(api_call, output_format='object'):
'data_name': eval_['oml:data_name'],
'function': eval_['oml:function'],
'upload_time': eval_['oml:upload_time'],
'uploader': int(eval_['oml:uploader']),
'uploader_name': user_dict[eval_['oml:uploader']],
'value': value,
'values': values,
'array_data': array_data}
Expand Down
4 changes: 3 additions & 1 deletion tests/test_evaluations/test_evaluation_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ def test_evaluation_list_filter_uploader_ID_16(self):

uploader_id = 16
evaluations = openml.evaluations.list_evaluations("predictive_accuracy",
uploader=[uploader_id])
uploader=[uploader_id],
output_format='dataframe')
self.assertEqual(evaluations['uploader'].unique(), [uploader_id])

self.assertGreater(len(evaluations), 50)

Expand Down