functions
openml.runs.functions
#
__list_runs
#
Helper function to parse API calls which are lists of runs
Source code in openml/runs/functions.py
delete_run
#
Delete run with id run_id
from the OpenML server.
You can only delete runs which you uploaded.
Parameters#
run_id : int OpenML id of the run
Returns#
bool True if the deletion was successful. False otherwise.
Source code in openml/runs/functions.py
format_prediction
#
format_prediction(task: OpenMLSupervisedTask, repeat: int, fold: int, index: int, prediction: str | int | float, truth: str | int | float, sample: int | None = None, proba: dict[str, float] | None = None) -> list[str | int | float]
Format the predictions in the specific order as required for the run results.
Parameters#
task: OpenMLSupervisedTask
Task for which to format the predictions.
repeat: int
From which repeat this predictions is made.
fold: int
From which fold this prediction is made.
index: int
For which index this prediction is made.
prediction: str, int or float
The predicted class label or value.
truth: str, int or float
The true class label or value.
sample: int, optional (default=None)
From which sample set this prediction is made.
Required only for LearningCurve tasks.
proba: Dict[str, float], optional (default=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 task.class_labels
.
E.g.: {"Iris-Setosa": 0.2, "Iris-Versicolor": 0.7, "Iris-Virginica": 0.1}
Returns#
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
1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 |
|
get_run
#
get_run(run_id: int, ignore_cache: bool = False) -> OpenMLRun
Gets run corresponding to run_id.
Parameters#
run_id : int
bool
Whether to ignore the cache. If true
this will download and overwrite the run xml
even if the requested run is already cached.
ignore_cache
Returns#
run : OpenMLRun Run corresponding to ID, fetched from the server.
Source code in openml/runs/functions.py
get_run_trace
#
get_run_trace(run_id: int) -> OpenMLRunTrace
Get the optimization trace object for a given run id.
Parameters#
run_id : int
Returns#
openml.runs.OpenMLTrace
Source code in openml/runs/functions.py
get_runs
#
get_runs(run_ids: list[int]) -> list[OpenMLRun]
Gets all runs in run_ids list.
Parameters#
run_ids : list of ints
Returns#
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
#
Initialized a model based on a run_id (i.e., using the exact same parameter settings)
Parameters#
run_id : int
The Openml run_id
strict_version: bool (default=True)
See flow_to_model
strict_version.
Returns#
model
Source code in openml/runs/functions.py
initialize_model_from_trace
#
initialize_model_from_trace(run_id: int, repeat: int, fold: int, iteration: int | None = None) -> Any
Initialize a model based on the parameters that were set by an optimization procedure (i.e., using the exact same parameter settings)
Parameters#
run_id : int The Openml run_id. Should contain a trace file, otherwise a OpenMLServerException is raised
int
The repeat nr (column in trace file)
int
The fold nr (column in trace file)
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
Returns#
model
Source code in openml/runs/functions.py
list_runs
#
list_runs(offset: int | None = None, size: int | None = None, id: list | None = None, task: list[int] | None = None, setup: list | None = None, flow: list | None = None, uploader: list | None = None, tag: str | None = None, study: int | None = None, display_errors: bool = False, task_type: TaskType | int | None = None) -> DataFrame
List all runs matching all of the given filters. (Supports large amount of results)
Parameters#
offset : int, optional the number of runs to skip, starting from the first size : int, optional the maximum number of runs to show
id : list, optional
task : list, optional
setup: list, optional
flow : list, optional
uploader : list, optional
tag : str, optional
study : int, optional
bool, optional (default=None)
Whether to list runs which have an error (for example a missing prediction file).
task_type : str, optional
Returns#
dataframe
Source code in openml/runs/functions.py
1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 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 |
|
run_exists
#
Checks whether a task/setup combination is already present on the server.
Parameters#
task_id : int
setup_id : int
Returns#
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
#
run_flow_on_task(flow: OpenMLFlow, task: OpenMLTask, avoid_duplicate_runs: bool | None = None, flow_tags: list[str] | None = None, seed: int | None = None, add_local_measures: bool = True, upload_flow: bool = False, n_jobs: int | None = None) -> OpenMLRun
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#
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.
task : OpenMLTask
Task to perform. This may be an OpenMLFlow instead if the first argument is an OpenMLTask.
avoid_duplicate_runs : bool, optional (default=None)
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.
If not set, it will use the default from your openml configuration (False if unset).
flow_tags : List[str], optional (default=None)
A list of tags that the flow should have at creation.
seed: int, optional (default=None)
Models that are not seeded will get this seed.
add_local_measures : bool, optional (default=True)
Determines whether to calculate a set of evaluation measures locally,
to later verify server behaviour.
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.
n_jobs : int (default=None)
The number of processes/threads to distribute the evaluation asynchronously.
If None
or 1
, then the evaluation is treated as synchronous and processed sequentially.
If -1
, then the job uses as many cores available.
Returns#
run : OpenMLRun Result of the run.
Source code in openml/runs/functions.py
178 179 180 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 |
|
run_model_on_task
#
run_model_on_task(model: Any, task: int | str | OpenMLTask, avoid_duplicate_runs: bool | None = None, flow_tags: list[str] | None = None, seed: int | None = None, add_local_measures: bool = True, upload_flow: bool = False, return_flow: bool = False, n_jobs: int | None = None) -> OpenMLRun | tuple[OpenMLRun, OpenMLFlow]
Run the model on the dataset defined by the task.
Parameters#
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.
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.
avoid_duplicate_runs : bool, optional (default=None)
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.
If not set, it will use the default from your openml configuration (False if unset).
flow_tags : List[str], optional (default=None)
A list of tags that the flow should have at creation.
seed: int, optional (default=None)
Models that are not seeded will get this seed.
add_local_measures : bool, optional (default=True)
Determines whether to calculate a set of evaluation measures locally,
to later verify server behaviour.
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.
return_flow : bool (default=False)
If True, returns the OpenMLFlow generated from the model in addition to the OpenMLRun.
n_jobs : int (default=None)
The number of processes/threads to distribute the evaluation asynchronously.
If None
or 1
, then the evaluation is treated as synchronous and processed sequentially.
If -1
, then the job uses as many cores available.
Returns#
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 |
|