sklearn.utils.metaestimators.if_delegate_has_method

sklearn.utils.metaestimators.if_delegate_has_method(delegate)[source]

Create a decorator for methods that are delegated to a sub-estimator.

Deprecated since version 1.3: if_delegate_has_method is deprecated in version 1.1 and will be removed in version 1.3. Use available_if instead.

This enables ducktyping by hasattr returning True according to the sub-estimator.

Parameters:
delegatestr, list of str or tuple of str

Name of the sub-estimator that can be accessed as an attribute of the base object. If a list or a tuple of names are provided, the first sub-estimator that is an attribute of the base object will be used.

Returns:
callable

Callable makes the decorated method available if the delegate has a method with the same name as the decorated method.