functions
__list_runs(api_call, output_format='dict')
¶
Helper function to parse API calls which are lists of runs
Source code in openml/runs/functions.py
delete_run(run_id)
¶
Delete run with id run_id
from the OpenML server.
You can only delete runs which you uploaded.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
run_id
|
int
|
OpenML id of the run |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the deletion was successful. False otherwise. |
Source code in openml/runs/functions.py
format_prediction(task, repeat, fold, index, prediction, truth, sample=None, proba=None)
¶
Format the predictions in the specific order as required for the run results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task
|
OpenMLSupervisedTask
|
Task for which to format the predictions. |
required |
repeat
|
int
|
From which repeat this predictions is made. |
required |
fold
|
int
|
From which fold this prediction is made. |
required |
index
|
int
|
For which index this prediction is made. |
required |
prediction
|
str | int | float
|
The predicted class label or value. |
required |
truth
|
str | int | float
|
The true class label or value. |
required |
sample
|
int | None
|
From which sample set this prediction is made. Required only for LearningCurve tasks. |
None
|
proba
|
dict[str, float] | None
|
For classification tasks only.
A mapping from each class label to their predicted probability.
The dictionary should contain an entry for each of the |
None
|
Returns:
Type | Description |
---|---|
A list with elements for the prediction results of a run.
|
|
The returned order of the elements is (if available):
|
[repeat, fold, sample, index, prediction, truth, *probabilities] |
This order follows the R Client API.
|
|
Source code in openml/runs/functions.py
1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 |
|
get_run(run_id, ignore_cache=False)
¶
Gets run corresponding to run_id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
run_id
|
int
|
|
required |
ignore_cache
|
bool
|
Whether to ignore the cache. If |
False
|
ignore_cache
|
bool
|
|
False
|
Returns:
Name | Type | Description |
---|---|---|
run |
OpenMLRun
|
Run corresponding to ID, fetched from the server. |
Source code in openml/runs/functions.py
get_run_trace(run_id)
¶
Get the optimization trace object for a given run id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
run_id
|
int
|
|
required |
Returns:
Type | Description |
---|---|
OpenMLTrace
|
|
Source code in openml/runs/functions.py
get_runs(run_ids)
¶
Gets all runs in run_ids list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
run_ids
|
list of ints
|
|
required |
Returns:
Name | Type | Description |
---|---|---|
runs |
list of OpenMLRun
|
List of runs corresponding to IDs, fetched from the server. |
Source code in openml/runs/functions.py
initialize_model_from_run(run_id)
¶
Initialized a model based on a run_id (i.e., using the exact same parameter settings)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
run_id
|
int
|
The Openml run_id |
required |
Returns:
Type | Description |
---|---|
model
|
|
Source code in openml/runs/functions.py
initialize_model_from_trace(run_id, repeat, fold, iteration=None)
¶
Initialize a model based on the parameters that were set by an optimization procedure (i.e., using the exact same parameter settings)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
run_id
|
int
|
The Openml run_id. Should contain a trace file, otherwise a OpenMLServerException is raised |
required |
repeat
|
int
|
The repeat nr (column in trace file) |
required |
fold
|
int
|
The fold nr (column in trace file) |
required |
iteration
|
int
|
The iteration nr (column in trace file). If None, the best (selected) iteration will be searched (slow), according to the selection criteria implemented in OpenMLRunTrace.get_selected_iteration |
None
|
Returns:
Type | Description |
---|---|
model
|
|
Source code in openml/runs/functions.py
list_runs(offset=None, size=None, id=None, task=None, setup=None, flow=None, uploader=None, tag=None, study=None, display_errors=False, output_format='dict', **kwargs)
¶
List all runs matching all of the given filters. (Supports large amount of results)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
int
|
the number of runs to skip, starting from the first |
None
|
size
|
int
|
the maximum number of runs to show |
None
|
id
|
list
|
|
None
|
task
|
list
|
|
None
|
setup
|
list | None
|
|
None
|
flow
|
list
|
|
None
|
uploader
|
list
|
|
None
|
tag
|
str
|
|
None
|
study
|
int
|
|
None
|
display_errors
|
(bool, optional(default=None))
|
Whether to list runs which have an error (for example a missing prediction file). |
False
|
output_format
|
Literal['dict', 'dataframe']
|
The parameter decides the format of the output. - If 'dict' the output is a dict of dict - If 'dataframe' the output is a pandas DataFrame |
'dict'
|
kwargs
|
dict
|
Legal filter operators: task_type. |
{}
|
Returns:
Type | Description |
---|---|
dict of dicts, or dataframe
|
|
Source code in openml/runs/functions.py
1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 |
|
run_exists(task_id, setup_id)
¶
Checks whether a task/setup combination is already present on the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id
|
int
|
|
required |
setup_id
|
int
|
|
required |
Returns:
Type | Description |
---|---|
Set run ids for runs where flow setup_id was run on task_id. Empty
|
set if it wasn't run yet. |
Source code in openml/runs/functions.py
run_flow_on_task(flow, task, avoid_duplicate_runs=True, flow_tags=None, seed=None, add_local_measures=True, upload_flow=False, dataset_format='dataframe', n_jobs=None)
¶
Run the model provided by the flow on the dataset defined by task.
Takes the flow and repeat information into account. The Flow may optionally be published.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flow
|
OpenMLFlow
|
A flow wraps a machine learning model together with relevant information. The model has a function fit(X,Y) and predict(X), all supervised estimators of scikit learn follow this definition of a model (https://scikit-learn.org/stable/tutorial/statistical_inference/supervised_learning.html) |
required |
task
|
OpenMLTask
|
Task to perform. This may be an OpenMLFlow instead if the first argument is an OpenMLTask. |
required |
avoid_duplicate_runs
|
(bool, optional(default=True))
|
If True, the run will throw an error if the setup/task combination is already present on the server. This feature requires an internet connection. |
True
|
avoid_duplicate_runs
|
(bool, optional(default=True))
|
If True, the run will throw an error if the setup/task combination is already present on the server. This feature requires an internet connection. |
True
|
flow_tags
|
(List[str], optional(default=None))
|
A list of tags that the flow should have at creation. |
None
|
seed
|
int | None
|
Models that are not seeded will get this seed. |
None
|
add_local_measures
|
(bool, optional(default=True))
|
Determines whether to calculate a set of evaluation measures locally, to later verify server behaviour. |
True
|
upload_flow
|
bool(default=False)
|
If True, upload the flow to OpenML if it does not exist yet. If False, do not upload the flow to OpenML. |
False
|
dataset_format
|
str(default='dataframe')
|
If 'array', the dataset is passed to the model as a numpy array. If 'dataframe', the dataset is passed to the model as a pandas dataframe. |
'dataframe'
|
n_jobs
|
int(default=None)
|
The number of processes/threads to distribute the evaluation asynchronously.
If |
None
|
Returns:
Name | Type | Description |
---|---|---|
run |
OpenMLRun
|
Result of the run. |
Source code in openml/runs/functions.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
|
run_model_on_task(model, task, avoid_duplicate_runs=True, flow_tags=None, seed=None, add_local_measures=True, upload_flow=False, return_flow=False, dataset_format='dataframe', n_jobs=None)
¶
Run the model on the dataset defined by the task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
sklearn model
|
A model which has a function fit(X,Y) and predict(X), all supervised estimators of scikit learn follow this definition of a model (https://scikit-learn.org/stable/tutorial/statistical_inference/supervised_learning.html) |
required |
task
|
OpenMLTask or int or str
|
Task to perform or Task id. This may be a model instead if the first argument is an OpenMLTask. |
required |
avoid_duplicate_runs
|
(bool, optional(default=True))
|
If True, the run will throw an error if the setup/task combination is already present on the server. This feature requires an internet connection. |
True
|
flow_tags
|
(List[str], optional(default=None))
|
A list of tags that the flow should have at creation. |
None
|
seed
|
int | None
|
Models that are not seeded will get this seed. |
None
|
add_local_measures
|
(bool, optional(default=True))
|
Determines whether to calculate a set of evaluation measures locally, to later verify server behaviour. |
True
|
upload_flow
|
bool(default=False)
|
If True, upload the flow to OpenML if it does not exist yet. If False, do not upload the flow to OpenML. |
False
|
return_flow
|
bool(default=False)
|
If True, returns the OpenMLFlow generated from the model in addition to the OpenMLRun. |
False
|
dataset_format
|
str(default='dataframe')
|
If 'array', the dataset is passed to the model as a numpy array. If 'dataframe', the dataset is passed to the model as a pandas dataframe. |
'dataframe'
|
n_jobs
|
int(default=None)
|
The number of processes/threads to distribute the evaluation asynchronously.
If |
None
|
Returns:
Name | Type | Description |
---|---|---|
run |
OpenMLRun
|
Result of the run. |
flow |
OpenMLFlow (optional, only if `return_flow` is True).
|
Flow generated from the model. |
Source code in openml/runs/functions.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|