openml.extensions.Extension

class openml.extensions.Extension

Defines the interface to connect machine learning libraries to OpenML-Python.

See openml.extension.sklearn.extension for an implementation to bootstrap from.

abstract 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.

Parameters
flowOpenMLFlow
Returns
bool
abstract classmethod can_handle_model(model: Any) → bool

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.

Parameters
modelAny
Returns
bool
abstract create_setup_string(self, model: Any) → str

Create a string which can be used to reinstantiate the given model.

Parameters
modelAny
Returns
str
abstract flow_to_model(self, flow: 'OpenMLFlow', initialize_with_defaults: bool = False) → Any

Instantiate a model from the flow representation.

Parameters
flowOpenMLFlow
initialize_with_defaultsbool, optional (default=False)

If this flag is set, the hyperparameter values of flows will be ignored and a flow with its defaults is returned.

Returns
Any
abstract get_version_information(self) → List[str]

List versions of libraries required by the flow.

Returns
List
abstract instantiate_model_from_hpo_class(self, model: Any, trace_iteration: 'OpenMLTraceIteration') → Any

Instantiate a base model which can be searched over by the hyperparameter optimization model.

Parameters
modelAny

A hyperparameter optimization model which defines the model to be instantiated.

trace_iterationOpenMLTraceIteration

Describing the hyperparameter settings to instantiate.

Returns
Any
abstract is_estimator(self, model: Any) → bool

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.

Parameters
modelAny
Returns
bool
abstract model_to_flow(self, model: Any) → 'OpenMLFlow'

Transform a model to a flow for uploading it to OpenML.

Parameters
modelAny
Returns
OpenMLFlow
abstract obtain_parameter_values(self, 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.

Parameters
flowOpenMLFlow

OpenMLFlow object (containing flow ids, i.e., it has to be downloaded from the server)

model: Any, optional (default=None)

The model from which to obtain the parameter values. Must match the flow signature. If None, use the model specified in OpenMLFlow.model.

Returns
list

A list of dicts, where each dict has the following entries: - oml:name : str: The OpenML parameter name - oml:value : mixed: A representation of the parameter value - oml:component : int: flow id to which the parameter belongs

abstract seed_model(self, model: Any, seed: Union[int, NoneType]) → Any

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.

Parameters
modelAny

The model to be seeded

seedint
Returns
model