@ingredient.capture
def get_instance(name, parameters, _log, _seed):
    'Get an instance of a model according to parameters in the configuration.\n\n    Also, check if the provided parameters fit to the signature of the model\n    class and log default values if not defined via the configuration.\n\n    '
    model_cls = getattr(models, name)
    signature = inspect.signature(model_cls)
    available_parameters = signature.parameters
    for key in parameters.keys():
        if (key not in available_parameters.keys()):
            raise ValueError(f"{key} is not available in {name}'s Constructor")
    optional_parameters = list(available_parameters.keys())[4:]
    for parameter_name in optional_parameters:
        parameter_keys = list(parameters.keys())
        if (parameter_name not in parameter_keys):
            if (parameter_name != 'random_state'):
                default = available_parameters[parameter_name].default
                _log.warning(f'Optional parameter {parameter_name} not explicitly defined, will run with {parameter_name}={default}')
            else:
                _log.info(f'Passing seed of experiment to model parameter `random_state`.')
                parameters['random_state'] = _seed
    return model_cls(**parameters)
Get an instance of a model according to parameters in the configuration.

Also, check if the provided parameters fit to the signature of the model
class and log default values if not defined via the configuration.
@ingredient.capture
def get_instance(name, parameters, _log, _seed):
    'Get an instance of a model according to parameters in the configuration.\n\n    Also, check if the provided parameters fit to the signature of the model\n    class and log default values if not defined via the configuration.\n\n    '
    model_cls = getattr(models, name)
    signature = inspect.signature(model_cls)
    available_parameters = signature.parameters
    for key in parameters.keys():
        if (key not in available_parameters.keys()):
            raise ValueError(f"{key} is not available in {name}'s Constructor")
    optional_parameters = list(available_parameters.keys())[4:]
    for parameter_name in optional_parameters:
        parameter_keys = list(parameters.keys())
        if (parameter_name not in parameter_keys):
            if (parameter_name != 'random_state'):
                default = available_parameters[parameter_name].default
                _log.warning(f'Optional parameter {parameter_name} not explicitly defined, will run with {parameter_name}={default}')
            else:
                _log.info(f'Passing seed of experiment to model parameter `random_state`.')
                parameters['random_state'] = _seed
    return model_cls(**parameters)