runs
openml.runs
#
OpenMLRun
#
OpenMLRun(task_id: int, flow_id: int | None, dataset_id: int | None, setup_string: str | None = None, output_files: dict[str, int] | None = None, setup_id: int | None = None, tags: list[str] | None = None, uploader: int | None = None, uploader_name: str | None = None, evaluations: dict | None = None, fold_evaluations: dict | None = None, sample_evaluations: dict | None = None, data_content: list[list] | None = None, trace: OpenMLRunTrace | None = None, model: object | None = None, task_type: str | None = None, task_evaluation_measure: str | None = None, flow_name: str | None = None, parameter_settings: list[dict[str, Any]] | None = None, predictions_url: str | None = None, task: OpenMLTask | None = None, flow: OpenMLFlow | None = None, run_id: int | None = None, description_text: str | None = None, run_details: str | None = None)
Bases: OpenMLBase
OpenML Run: result of running a model on an OpenML dataset.
| PARAMETER | DESCRIPTION |
|---|---|
task_id
|
The ID of the OpenML task associated with the run.
TYPE:
|
flow_id
|
The ID of the OpenML flow associated with the run.
TYPE:
|
dataset_id
|
The ID of the OpenML dataset used for the run.
TYPE:
|
setup_string
|
The setup string of the run.
TYPE:
|
output_files
|
Specifies where each related file can be found.
TYPE:
|
setup_id
|
An integer representing the ID of the setup used for the run.
TYPE:
|
tags
|
Representing the tags associated with the run.
TYPE:
|
uploader
|
User ID of the uploader.
TYPE:
|
uploader_name
|
The name of the person who uploaded the run.
TYPE:
|
evaluations
|
Representing the evaluations of the run.
TYPE:
|
fold_evaluations
|
The evaluations of the run for each fold.
TYPE:
|
sample_evaluations
|
The evaluations of the run for each sample.
TYPE:
|
data_content
|
The predictions generated from executing this run.
TYPE:
|
trace
|
The trace containing information on internal model evaluations of this run.
TYPE:
|
model
|
The untrained model that was evaluated in the run.
TYPE:
|
task_type
|
The type of the OpenML task associated with the run.
TYPE:
|
task_evaluation_measure
|
The evaluation measure used for the task.
TYPE:
|
flow_name
|
The name of the OpenML flow associated with the run.
TYPE:
|
parameter_settings
|
Representing the parameter settings used for the run.
TYPE:
|
predictions_url
|
The URL of the predictions file.
TYPE:
|
task
|
An instance of the OpenMLTask class, representing the OpenML task associated with the run.
TYPE:
|
flow
|
An instance of the OpenMLFlow class, representing the OpenML flow associated with the run.
TYPE:
|
run_id
|
The ID of the run.
TYPE:
|
description_text
|
Description text to add to the predictions file. If left None, is set to the time the arff file is generated.
TYPE:
|
run_details
|
Description of the run stored in the run meta-data.
TYPE:
|
Source code in openml/runs/run.py
openml_url
property
#
The URL of the object on the server, if it was uploaded, else None.
from_filesystem
classmethod
#
from_filesystem(directory: str | Path, expect_model: bool = True) -> OpenMLRun
The inverse of the to_filesystem method. Instantiates an OpenMLRun object based on files stored on the file system.
| PARAMETER | DESCRIPTION |
|---|---|
directory
|
a path leading to the folder where the results are stored
TYPE:
|
expect_model
|
if True, it requires the model pickle to be present, and an error will be thrown if not. Otherwise, the model might or might not be present.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
run
|
the re-instantiated run object
TYPE:
|
Source code in openml/runs/run.py
get_metric_fn
#
Calculates metric scores based on predicted values. Assumes the run has been executed locally (and contains run_data). Furthermore, it assumes that the 'correct' or 'truth' attribute is specified in the arff (which is an optional field, but always the case for openml-python runs)
| PARAMETER | DESCRIPTION |
|---|---|
sklearn_fn
|
a function pointer to a sklearn function that
accepts
TYPE:
|
kwargs
|
kwargs for the function
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
scores
|
metric results
TYPE:
|
Source code in openml/runs/run.py
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 | |
open_in_browser
#
Opens the OpenML web page corresponding to this object in your default browser.
Source code in openml/base.py
publish
#
publish() -> OpenMLRun
Publish the run object on the OpenML server.
Source code in openml/runs/run.py
push_tag
#
Push a tag for this run on the OpenML server.
Source code in openml/runs/run.py
remove_tag
#
Remove a tag for this run on the OpenML server.
Source code in openml/runs/run.py
to_filesystem
#
The inverse of the from_filesystem method. Serializes a run on the filesystem, to be uploaded later.
| PARAMETER | DESCRIPTION |
|---|---|
directory
|
a path leading to the folder where the results will be stored. Should be empty
TYPE:
|
store_model
|
if True, a model will be pickled as well. As this is the most storage expensive part, it is often desirable to not store the model.
TYPE:
|
Source code in openml/runs/run.py
url_for_id
classmethod
#
Return the OpenML URL for the object of the class entity with the given id.
OpenMLRunTrace
#
OpenMLRunTrace(run_id: int | None, trace_iterations: dict[tuple[int, int, int], OpenMLTraceIteration])
OpenML Run Trace: parsed output from Run Trace call
| PARAMETER | DESCRIPTION |
|---|---|
run_id
|
OpenML run id.
TYPE:
|
trace_iterations
|
Mapping from key
TYPE:
|
| PARAMETER | DESCRIPTION |
|---|---|
run_id
|
Id for which the trace content is to be stored.
TYPE:
|
trace_iterations
|
The trace content obtained by running a flow on a task.
TYPE:
|
Source code in openml/runs/trace.py
generate
classmethod
#
generate(attributes: list[tuple[str, str]], content: list[list[int | float | str]]) -> OpenMLRunTrace
Generates an OpenMLRunTrace.
Generates the trace object from the attributes and content extracted while running the underlying flow.
| PARAMETER | DESCRIPTION |
|---|---|
attributes
|
List of tuples describing the arff attributes.
TYPE:
|
content
|
List of lists containing information about the individual tuning runs.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
OpenMLRunTrace
|
|
Source code in openml/runs/trace.py
get_selected_iteration
#
Returns the trace iteration that was marked as selected. In case multiple are marked as selected (should not happen) the first of these is returned
| PARAMETER | DESCRIPTION |
|---|---|
fold
|
TYPE:
|
repeat
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
The trace iteration from the given fold and repeat that was selected as the best iteration by the search procedure |
Source code in openml/runs/trace.py
merge_traces
classmethod
#
merge_traces(traces: list[OpenMLRunTrace]) -> OpenMLRunTrace
Merge multiple traces into a single trace.
| PARAMETER | DESCRIPTION |
|---|---|
cls
|
Type of the trace object to be created.
TYPE:
|
traces
|
List of traces to merge.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
OpenMLRunTrace
|
A trace object representing the merged traces. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the parameters in the iterations of the traces being merged are not equal. If a key (repeat, fold, iteration) is encountered twice while merging the traces. |
Source code in openml/runs/trace.py
trace_from_arff
classmethod
#
trace_from_arff(arff_obj: dict[str, Any]) -> OpenMLRunTrace
Generate trace from arff trace.
Creates a trace file from arff object (for example, generated by a local run).
| PARAMETER | DESCRIPTION |
|---|---|
arff_obj
|
LIAC arff obj, dict containing attributes, relation, data.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
OpenMLRunTrace
|
|
Source code in openml/runs/trace.py
trace_from_xml
classmethod
#
trace_from_xml(xml: str | Path | IO) -> OpenMLRunTrace
Generate trace from xml.
Creates a trace file from the xml description.
| PARAMETER | DESCRIPTION |
|---|---|
xml
|
An xml description that can be either a
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
run
|
Object containing the run id and a dict containing the trace iterations.
TYPE:
|
Source code in openml/runs/trace.py
trace_to_arff
#
Generate the arff dictionary for uploading predictions to the server.
Uses the trace object to generate an arff dictionary representation.
| RETURNS | DESCRIPTION |
|---|---|
arff_dict
|
Dictionary representation of the ARFF file that will be uploaded. Contains information about the optimization trace.
TYPE:
|
Source code in openml/runs/trace.py
OpenMLTraceIteration
dataclass
#
OpenMLTraceIteration(repeat: int, fold: int, iteration: int, evaluation: float, selected: bool, setup_string: dict[str, str] | None = None, parameters: dict[str, str | int | float] | None = None)
OpenML Trace Iteration: parsed output from Run Trace call
Exactly one of setup_string or parameters must be provided.
| PARAMETER | DESCRIPTION |
|---|---|
repeat
|
repeat number (in case of no repeats: 0)
TYPE:
|
fold
|
fold number (in case of no folds: 0)
TYPE:
|
iteration
|
iteration number of optimization procedure
TYPE:
|
setup_string
|
json string representing the parameters
If not provided,
TYPE:
|
evaluation
|
The evaluation that was awarded to this trace iteration. Measure is defined by the task
TYPE:
|
selected
|
Whether this was the best of all iterations, and hence selected for making predictions. Per fold/repeat there should be only one iteration selected
TYPE:
|
parameters
|
Dictionary specifying parameter names and their values.
If not provided,
TYPE:
|
get_parameters
#
Get the parameters of this trace iteration.
Source code in openml/runs/trace.py
delete_run
#
Delete run with id run_id from the OpenML server.
You can only delete runs which you uploaded.
| PARAMETER | DESCRIPTION |
|---|---|
run_id
|
OpenML id of the run
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the deletion was successful. False otherwise. |
Source code in openml/runs/functions.py
get_run
#
get_run(run_id: int, ignore_cache: bool = False) -> OpenMLRun
Gets run corresponding to run_id.
| PARAMETER | DESCRIPTION |
|---|---|
run_id
|
TYPE:
|
ignore_cache
|
Whether to ignore the cache. If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
run
|
Run corresponding to ID, fetched from the server.
TYPE:
|
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.
| PARAMETER | DESCRIPTION |
|---|---|
run_id
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
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.
| PARAMETER | DESCRIPTION |
|---|---|
run_ids
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
runs
|
List of runs corresponding to IDs, fetched from the server.
TYPE:
|
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)
| PARAMETER | DESCRIPTION |
|---|---|
run_id
|
The Openml run_id
TYPE:
|
strict_version
|
See
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
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)
| PARAMETER | DESCRIPTION |
|---|---|
run_id
|
The Openml run_id. Should contain a trace file, otherwise a OpenMLServerException is raised
TYPE:
|
repeat
|
The repeat nr (column in trace file)
TYPE:
|
fold
|
The fold nr (column in trace file)
TYPE:
|
iteration
|
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
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
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)
| PARAMETER | DESCRIPTION |
|---|---|
offset
|
the number of runs to skip, starting from the first
TYPE:
|
size
|
the maximum number of runs to show
TYPE:
|
id
|
TYPE:
|
task
|
TYPE:
|
setup
|
TYPE:
|
flow
|
TYPE:
|
uploader
|
TYPE:
|
tag
|
TYPE:
|
study
|
TYPE:
|
display_errors
|
Whether to list runs which have an error (for example a missing prediction file).
TYPE:
|
task_type
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dataframe
|
|
Source code in openml/runs/functions.py
1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 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 | |
run_exists
#
Checks whether a task/setup combination is already present on the server.
| PARAMETER | DESCRIPTION |
|---|---|
task_id
|
TYPE:
|
setup_id
|
TYPE:
|
| RETURNS | 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
#
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.
| PARAMETER | DESCRIPTION |
|---|---|
flow
|
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.
TYPE:
|
task
|
Task to perform. This may be an OpenMLFlow instead if the first argument is an OpenMLTask.
TYPE:
|
avoid_duplicate_runs
|
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).
TYPE:
|
flow_tags
|
A list of tags that the flow should have at creation.
TYPE:
|
seed
|
Models that are not seeded will get this seed.
TYPE:
|
add_local_measures
|
Determines whether to calculate a set of evaluation measures locally, to later verify server behaviour.
TYPE:
|
upload_flow
|
If True, upload the flow to OpenML if it does not exist yet. If False, do not upload the flow to OpenML.
TYPE:
|
n_jobs
|
The number of processes/threads to distribute the evaluation asynchronously.
If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
run
|
Result of the run.
TYPE:
|
Source code in openml/runs/functions.py
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | |
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.
| PARAMETER | DESCRIPTION |
|---|---|
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.
TYPE:
|
task
|
Task to perform or Task id. This may be a model instead if the first argument is an OpenMLTask.
TYPE:
|
avoid_duplicate_runs
|
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).
TYPE:
|
flow_tags
|
A list of tags that the flow should have at creation.
TYPE:
|
seed
|
Models that are not seeded will get this seed.
TYPE:
|
add_local_measures
|
Determines whether to calculate a set of evaluation measures locally, to later verify server behaviour.
TYPE:
|
upload_flow
|
If True, upload the flow to OpenML if it does not exist yet. If False, do not upload the flow to OpenML.
TYPE:
|
return_flow
|
If True, returns the OpenMLFlow generated from the model in addition to the OpenMLRun.
TYPE:
|
n_jobs
|
The number of processes/threads to distribute the evaluation asynchronously.
If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
run
|
Result of the run.
TYPE:
|
flow
|
Flow generated from the model.
TYPE:
|
Examples:
>>> import openml
>>> import openml_sklearn
>>> from sklearn.tree import DecisionTreeClassifier
>>> clf = DecisionTreeClassifier()
>>> task = openml.tasks.get_task(6)
>>> run = openml.runs.run_model_on_task(clf, task)
Source code in openml/runs/functions.py
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 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |