yobx.sklearn.register#

yobx.sklearn.register.get_sklearn_converter(cls: type)[source]#

Returns the converter for a specific type.

yobx.sklearn.register.get_sklearn_converters()[source]#

Returns all registered converters as a mapping from type to converter function.

yobx.sklearn.register.get_sklearn_estimator_coverage(libraries: str | Tuple[str, ...] = 'all', rst: bool = False)[source]#

Returns a coverage report for scikit-learn estimators.

Enumerates every estimator/transformer exposed by sklearn.utils.all_estimators() but also by other libraries following the same design and supported by this package. It reports which ones already have a converter registered in yobx.sklearn, when that package is installed.

Parameters:
  • libraries‘all’ to include all available modules, or a list of libraries to include such as ('sklearn', 'lightgbm', ...)

  • rst – returns the information a RST text

Returns:

Each entry is a dict with the following keys:

"category"

Estimator class name (str).

"name"

Estimator class name (str).

"cls"

The estimator class itself.

"module"

Public sklearn module path (private submodules stripped).

"yobx"

the converting function if a converter is registered in yobx.sklearn.

Return type:

list[dict]

yobx.sklearn.register.has_sklearn_converter(cls: type)[source]#

Returns if the model has a converter.

yobx.sklearn.register.register_sklearn_converter(cls: type | Tuple[type, ...], sklearn_version: str | None = None, other_versions: Dict[str, str] | None = None) Callable[source]#

Registers a converter for a specific class following scikit-learn API. If version is defined, the converter is register only if the version of scikit-learn is equal or more recent to this one.

Parameters:
  • cls – class to register

  • sklearn_version – first version of scikit-learn it can work

  • other_versions – same for any particular package the class comes from, example: {'xgboost': '3.4'}

Returns:

Callable

yobx.sklearn.register.sklearn_exportable_methods() Tuple[str, ...][source]#

Returns the methods which can be exported into ONNX.

<<<

from yobx.sklearn.register import sklearn_exportable_methods

print(sklearn_exportable_methods())

>>>

    ('transform', 'predict', 'predict_proba', 'mahalanobis', 'score_samples')