extension_interface
openml.extensions.extension_interface
#
Extension
#
Bases: ABC
Defines the interface to connect machine learning libraries to OpenML-Python.
See openml.extension.sklearn.extension for an implementation to bootstrap from.
can_handle_flow
abstractmethod
classmethod
#
can_handle_flow(flow: OpenMLFlow) -> bool
Check whether a given flow can be handled by this extension.
This is typically done by parsing the external_version field.
| PARAMETER | DESCRIPTION |
|---|---|
flow
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
|
Source code in openml/extensions/extension_interface.py
can_handle_model
abstractmethod
classmethod
#
Check whether a model flow can be handled by this extension.
This is typically done by checking the type of the model, or the package it belongs to.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
|
Source code in openml/extensions/extension_interface.py
check_if_model_fitted
abstractmethod
#
Returns True/False denoting if the model has already been fitted/trained.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
|
Source code in openml/extensions/extension_interface.py
create_setup_string
abstractmethod
#
Create a string which can be used to reinstantiate the given model.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
flow_to_model
abstractmethod
#
flow_to_model(flow: OpenMLFlow, initialize_with_defaults: bool = False, strict_version: bool = True) -> Any
Instantiate a model from the flow representation.
| PARAMETER | DESCRIPTION |
|---|---|
flow
|
TYPE:
|
initialize_with_defaults
|
If this flag is set, the hyperparameter values of flows will be ignored and a flow with its defaults is returned.
TYPE:
|
strict_version
|
Whether to fail if version requirements are not fulfilled.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Any
|
|
Source code in openml/extensions/extension_interface.py
get_version_information
abstractmethod
#
List versions of libraries required by the flow.
| RETURNS | DESCRIPTION |
|---|---|
List
|
|
instantiate_model_from_hpo_class
abstractmethod
#
instantiate_model_from_hpo_class(model: Any, trace_iteration: OpenMLTraceIteration) -> Any
Instantiate a base model which can be searched over by the hyperparameter optimization model.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
A hyperparameter optimization model which defines the model to be instantiated.
TYPE:
|
trace_iteration
|
Describing the hyperparameter settings to instantiate.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Any
|
|
Source code in openml/extensions/extension_interface.py
is_estimator
abstractmethod
#
Check whether the given model is an estimator for the given extension.
This function is only required for backwards compatibility and will be removed in the near future.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
|
Source code in openml/extensions/extension_interface.py
model_to_flow
abstractmethod
#
model_to_flow(model: Any) -> OpenMLFlow
Transform a model to a flow for uploading it to OpenML.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
OpenMLFlow
|
|
obtain_parameter_values
abstractmethod
#
obtain_parameter_values(flow: OpenMLFlow, model: Any = None) -> list[dict[str, Any]]
Extracts all parameter settings required for the flow from the model.
If no explicit model is provided, the parameters will be extracted from flow.model
instead.
| PARAMETER | DESCRIPTION |
|---|---|
flow
|
OpenMLFlow object (containing flow ids, i.e., it has to be downloaded from the server)
TYPE:
|
model
|
The model from which to obtain the parameter values. Must match the flow signature.
If None, use the model specified in
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list
|
A list of dicts, where each dict has the following entries:
- |
Source code in openml/extensions/extension_interface.py
seed_model
abstractmethod
#
Set the seed of all the unseeded components of a model and return the seeded model.
Required so that all seed information can be uploaded to OpenML for reproducible results.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
The model to be seeded
TYPE:
|
seed
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
model
|
|