def test_get_extension_by_model(self): self.assertIsNone(get_extension_by_model(DummyModel())) with self.assertRaisesRegex(ValueError, 'No extension registered which can handle model:'): get_extension_by_model(DummyModel(), raise_if_no_extension=True) register_extension(DummyExtension1) self.assertIsInstance(get_extension_by_model(DummyModel()), DummyExtension1) register_extension(DummyExtension2) self.assertIsInstance(get_extension_by_model(DummyModel()), DummyExtension1) register_extension(DummyExtension1) with self.assertRaisesRegex( ValueError, 'Multiple extensions registered which can handle model:', ): get_extension_by_model(DummyModel())
def test_get_extension_by_flow(self): self.assertIsNone(get_extension_by_flow(DummyFlow())) with self.assertRaisesRegex( ValueError, "No extension registered which can handle flow:"): get_extension_by_flow(DummyFlow(), raise_if_no_extension=True) register_extension(DummyExtension1) self.assertIsInstance(get_extension_by_flow(DummyFlow()), DummyExtension1) register_extension(DummyExtension2) self.assertIsInstance(get_extension_by_flow(DummyFlow()), DummyExtension1) register_extension(DummyExtension1) with self.assertRaisesRegex( ValueError, "Multiple extensions registered which can handle flow:", ): get_extension_by_flow(DummyFlow())
'oml:value': value, 'oml:component': flow.flow_id }) return parameter_settings def instantiate_model_from_hpo_class( self, model: Any, trace_iteration: OpenMLTraceIteration, ) -> Any: """Instantiate a ``base_estimator`` which can be searched over by the hyperparameter optimization model (UNUSED) Parameters ---------- model : Any A hyperparameter optimization model which defines the model to be instantiated. trace_iteration : OpenMLTraceIteration Describing the hyperparameter settings to instantiate. Returns ------- Any """ return model register_extension(OnnxExtension)
flow_structure = flow.get_structure('name') if openml_parameter.flow_name not in flow_structure: raise ValueError('Obtained OpenMLParameter and OpenMLFlow do not correspond. ') name = openml_parameter.flow_name # for PEP8 return '__'.join(flow_structure[name] + [openml_parameter.parameter_name]) def instantiate_model_from_hpo_class( self, model: Any, trace_iteration: OpenMLTraceIteration, ) -> Any: """Instantiate a ``base_estimator`` which can be searched over by the hyperparameter optimization model (UNUSED) Parameters ---------- model : Any A hyperparameter optimization model which defines the model to be instantiated. trace_iteration : OpenMLTraceIteration Describing the hyperparameter settings to instantiate. Returns ------- Any """ return model register_extension(KerasExtension)
# License: BSD 3-Clause from .extension import SklearnExtension from openml.extensions import register_extension __all__ = ['SklearnExtension'] register_extension(SklearnExtension)
from .extension import PytorchExtension from . import config from . import layers from openml.extensions import register_extension __all__ = ['PytorchExtension', 'config', 'layers'] register_extension(PytorchExtension)
from .extension import MXNetExtension from .config import Config from openml.extensions import register_extension __all__ = ['MXNetExtension', 'Config'] register_extension(MXNetExtension)
import os from .extension import TensorflowExtension from openml.extensions import register_extension from . import config __all__ = ['TensorflowExtension', 'config'] register_extension(TensorflowExtension)
import os from .extension import TFExtension from openml.extensions import register_extension __all__ = ['TFExtension'] register_extension(TFExtension)