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.
Source code in openml/extensions/extension_interface.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 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 176 177 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 |
|
can_handle_flow(flow)
abstractmethod
classmethod
¶
Check whether a given flow can be handled by this extension.
This is typically done by parsing the external_version
field.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flow
|
OpenMLFlow
|
|
required |
Returns:
Type | Description |
---|---|
bool
|
|
Source code in openml/extensions/extension_interface.py
can_handle_model(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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Any
|
|
required |
Returns:
Type | Description |
---|---|
bool
|
|
Source code in openml/extensions/extension_interface.py
check_if_model_fitted(model)
abstractmethod
¶
Returns True/False denoting if the model has already been fitted/trained.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Any
|
|
required |
Returns:
Type | Description |
---|---|
bool
|
|
Source code in openml/extensions/extension_interface.py
create_setup_string(model)
abstractmethod
¶
Create a string which can be used to reinstantiate the given model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Any
|
|
required |
Returns:
Type | Description |
---|---|
str
|
|
flow_to_model(flow, initialize_with_defaults=False, strict_version=True)
abstractmethod
¶
Instantiate a model from the flow representation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flow
|
OpenMLFlow
|
|
required |
initialize_with_defaults
|
(bool, optional(default=False))
|
If this flag is set, the hyperparameter values of flows will be ignored and a flow with its defaults is returned. |
False
|
strict_version
|
bool
|
Whether to fail if version requirements are not fulfilled. |
True
|
Returns:
Type | Description |
---|---|
Any
|
|
Source code in openml/extensions/extension_interface.py
get_version_information()
abstractmethod
¶
List versions of libraries required by the flow.
Returns:
Type | Description |
---|---|
List
|
|
instantiate_model_from_hpo_class(model, trace_iteration)
abstractmethod
¶
Instantiate a base model which can be searched over by the hyperparameter optimization model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Any
|
A hyperparameter optimization model which defines the model to be instantiated. |
required |
trace_iteration
|
OpenMLTraceIteration
|
Describing the hyperparameter settings to instantiate. |
required |
Returns:
Type | Description |
---|---|
Any
|
|
Source code in openml/extensions/extension_interface.py
is_estimator(model)
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Any
|
|
required |
Returns:
Type | Description |
---|---|
bool
|
|
Source code in openml/extensions/extension_interface.py
model_to_flow(model)
abstractmethod
¶
Transform a model to a flow for uploading it to OpenML.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Any
|
|
required |
Returns:
Type | Description |
---|---|
OpenMLFlow
|
|
obtain_parameter_values(flow, model=None)
abstractmethod
¶
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:
Name | Type | Description | Default |
---|---|---|---|
flow
|
OpenMLFlow
|
OpenMLFlow object (containing flow ids, i.e., it has to be downloaded from the server) |
required |
model
|
Any
|
The model from which to obtain the parameter values. Must match the flow signature.
If None, use the model specified in |
None
|
Returns:
Type | Description |
---|---|
list
|
A list of dicts, where each dict has the following entries:
- |
Source code in openml/extensions/extension_interface.py
seed_model(model, seed)
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Any
|
The model to be seeded |
required |
seed
|
int
|
|
required |
Returns:
Type | Description |
---|---|
model
|
|