vertebrae.extractors.sklearn

Scikit-learn transformer and pipeline extractors.

Classes

SklearnExtractor

Wrap a scikit-learn transformer or pipeline as an extractor.

Module Contents

class vertebrae.extractors.sklearn.SklearnExtractor(name, pipeline, already_fitted=False, extractor_type='unsupervised_fitted', max_dense_bytes=2000000000, allow_sparse=False, cache_identity=None)[source]

Wrap a scikit-learn transformer or pipeline as an extractor.

Parameters:
  • name (str) – User-facing extractor name.

  • pipeline (Any) – Object exposing fit, transform, or fit_transform.

  • already_fitted (bool) – Whether to skip fitting and call only transform.

  • extractor_type (str) – Extractor family metadata.

  • max_dense_bytes (int) – Maximum allowed sparse-to-dense conversion size.

  • allow_sparse (bool) – Whether sparse pipeline outputs should be preserved.

  • cache_identity (Optional[str])

fit(X, y=None)[source]

Fit the wrapped scikit-learn object when needed.

Parameters:
  • X (Any) – Input samples.

  • y (Any) – Optional labels.

Returns:

This extractor.

Return type:

SklearnExtractor

transform(X)[source]

Transform inputs with the wrapped scikit-learn object.

Parameters:

X (Any) – Input samples.

Returns:

Dense or sparse numeric embedding matrix.

Return type:

numpy.ndarray

fit_transform(X, y=None)[source]

Fit the pipeline if needed and transform inputs.

Parameters:
  • X (Any) – Input samples.

  • y (Any) – Optional labels.

Returns:

Dense or sparse numeric embedding matrix.

Return type:

numpy.ndarray

recipe()[source]

Return a serializable scikit-learn extractor recipe.

Returns:

JSON-compatible recipe dictionary.

Return type:

Dict[str, Any]