22import xmltodict
33import pandas as pd
44from typing import Union , List , Optional , Dict
5+ import collections
56
67import openml .utils
78import openml ._api_calls
@@ -19,6 +20,7 @@ def list_evaluations(
1920 uploader : Optional [List ] = None ,
2021 tag : Optional [str ] = None ,
2122 per_fold : Optional [bool ] = None ,
23+ sort_order : Optional [str ] = None ,
2224 output_format : str = 'object'
2325) -> Union [Dict , pd .DataFrame ]:
2426 """
@@ -48,6 +50,9 @@ def list_evaluations(
4850
4951 per_fold : bool, optional
5052
53+ sort_order : str, optional
54+ order of sorting evaluations, ascending ("asc") or descending ("desc")
55+
5156 output_format: str, optional (default='object')
5257 The parameter decides the format of the output.
5358 - If 'object' the output is a dict of OpenMLEvaluation objects
@@ -77,6 +82,7 @@ def list_evaluations(
7782 flow = flow ,
7883 uploader = uploader ,
7984 tag = tag ,
85+ sort_order = sort_order ,
8086 per_fold = per_fold_str )
8187
8288
@@ -87,6 +93,7 @@ def _list_evaluations(
8793 setup : Optional [List ] = None ,
8894 flow : Optional [List ] = None ,
8995 uploader : Optional [List ] = None ,
96+ sort_order : Optional [str ] = None ,
9097 output_format : str = 'object' ,
9198 ** kwargs
9299) -> Union [Dict , pd .DataFrame ]:
@@ -114,6 +121,9 @@ def _list_evaluations(
114121 kwargs: dict, optional
115122 Legal filter operators: tag, limit, offset.
116123
124+ sort_order : str, optional
125+ order of sorting evaluations, ascending ("asc") or descending ("desc")
126+
117127 output_format: str, optional (default='dict')
118128 The parameter decides the format of the output.
119129 - If 'dict' the output is a dict of dict
@@ -141,6 +151,8 @@ def _list_evaluations(
141151 api_call += "/flow/%s" % ',' .join ([str (int (i )) for i in flow ])
142152 if uploader is not None :
143153 api_call += "/uploader/%s" % ',' .join ([str (int (i )) for i in uploader ])
154+ if sort_order is not None :
155+ api_call += "/sort_order/%s" % sort_order
144156
145157 return __list_evaluations (api_call , output_format = output_format )
146158
@@ -157,7 +169,7 @@ def __list_evaluations(api_call, output_format='object'):
157169 assert type (evals_dict ['oml:evaluations' ]['oml:evaluation' ]) == list , \
158170 type (evals_dict ['oml:evaluations' ])
159171
160- evals = dict ()
172+ evals = collections . OrderedDict ()
161173 for eval_ in evals_dict ['oml:evaluations' ]['oml:evaluation' ]:
162174 run_id = int (eval_ ['oml:run_id' ])
163175 value = None
0 commit comments