openml.flows
.OpenMLFlow¶
- class openml.flows.OpenMLFlow(name: str, description: str, model: object, components: dict, parameters: dict, parameters_meta_info: dict, external_version: str, tags: list, language: str, dependencies: str, class_name: str | None = None, custom_name: str | None = None, binary_url: str | None = None, binary_format: str | None = None, binary_md5: str | None = None, uploader: str | None = None, upload_date: str | None = None, flow_id: int | None = None, extension: Extension | None = None, version: str | None = None)¶
OpenML Flow. Stores machine learning models.
Flows should not be generated manually, but by the function
openml.flows.create_flow_from_model()
. Using this helper function ensures that all relevant fields are filled in.Implements openml.implementation.upload.xsd.
- Parameters:
- namestr
Name of the flow. Is used together with the attribute external_version as a unique identifier of the flow.
- descriptionstr
Human-readable description of the flow (free text).
- modelobject
ML model which is described by this flow.
- componentsOrderedDict
Mapping from component identifier to an OpenMLFlow object. Components are usually subfunctions of an algorithm (e.g. kernels), base learners in ensemble algorithms (decision tree in adaboost) or building blocks of a machine learning pipeline. Components are modeled as independent flows and can be shared between flows (different pipelines can use the same components).
- parametersOrderedDict
Mapping from parameter name to the parameter default value. The parameter default value must be of type str, so that the respective toolbox plugin can take care of casting the parameter default value to the correct type.
- parameters_meta_infoOrderedDict
Mapping from parameter name to dict. Stores additional information for each parameter. Required keys are data_type and description.
- external_versionstr
Version number of the software the flow is implemented in. Is used together with the attribute name as a uniquer identifier of the flow.
- tagslist
List of tags. Created on the server by other API calls.
- languagestr
Natural language the flow is described in (not the programming language).
- dependenciesstr
A list of dependencies necessary to run the flow. This field should contain all libraries the flow depends on. To allow reproducibility it should also specify the exact version numbers.
- class_namestr, optional
The development language name of the class which is described by this flow.
- custom_namestr, optional
Custom name of the flow given by the owner.
- binary_urlstr, optional
Url from which the binary can be downloaded. Added by the server. Ignored when uploaded manually. Will not be used by the python API because binaries aren’t compatible across machines.
- binary_formatstr, optional
Format in which the binary code was uploaded. Will not be used by the python API because binaries aren’t compatible across machines.
- binary_md5str, optional
MD5 checksum to check if the binary code was correctly downloaded. Will not be used by the python API because binaries aren’t compatible across machines.
- uploaderstr, optional
OpenML user ID of the uploader. Filled in by the server.
- upload_datestr, optional
Date the flow was uploaded. Filled in by the server.
- flow_idint, optional
Flow ID. Assigned by the server.
- extensionExtension, optional
The extension for a flow (e.g., sklearn).
- versionstr, optional
OpenML version of the flow. Assigned by the server.
- classmethod from_filesystem(input_directory: str | Path) OpenMLFlow ¶
Read a flow from an XML in input_directory on the filesystem.
- get_structure(key_item: str) dict[str, list[str]] ¶
Returns for each sub-component of the flow the path of identifiers that should be traversed to reach this component. The resulting dict maps a key (identifying a flow by either its id, name or fullname) to the parameter prefix.
- Parameters:
- key_item: str
The flow attribute that will be used to identify flows in the structure. Allowed values {flow_id, name}
- Returns:
- dict[str, List[str]]
The flow structure
- get_subflow(structure: list[str]) OpenMLFlow ¶
Returns a subflow from the tree of dependencies.
- Parameters:
- structure: list[str]
A list of strings, indicating the location of the subflow
- Returns:
- OpenMLFlow
The OpenMLFlow that corresponds to the structure
- property id: int | None¶
The ID of the flow.
- open_in_browser() None ¶
Opens the OpenML web page corresponding to this object in your default browser.
- property openml_url: str | None¶
The URL of the object on the server, if it was uploaded, else None.
- publish(raise_error_if_exists: bool = False) OpenMLFlow ¶
Publish this flow to OpenML server.
Raises a PyOpenMLError if the flow exists on the server, but self.flow_id does not match the server known flow id.
- Parameters:
- raise_error_if_existsbool, optional (default=False)
If True, raise PyOpenMLError if the flow exists on the server. If False, update the local flow to match the server flow.
- Returns:
- selfOpenMLFlow
- push_tag(tag: str) None ¶
Annotates this entity with a tag on the server.
- Parameters:
- tagstr
Tag to attach to the flow.
- remove_tag(tag: str) None ¶
Removes a tag from this entity on the server.
- Parameters:
- tagstr
Tag to attach to the flow.
- to_filesystem(output_directory: str | Path) None ¶
Write a flow to the filesystem as XML to output_directory.
- classmethod url_for_id(id_: int) str ¶
Return the OpenML URL for the object of the class entity with the given id.