Skip to main content
Wrap a scikit-learn estimator (or Pipeline) with a transparent proxy that opens scopes around fit, predict, transform, fit_transform, predict_proba, and score. sklearn has no callback API, so instrumentation is opt-in via explicit wrapping.

Signature

Parameters

NameTypePurpose
estimatoranyAn sklearn estimator or sklearn.pipeline.Pipeline.
Any non-sklearn object passes through unchanged (documented passthrough).

Behavior

The returned object is a thin proxy:
  • fit, predict, transform, fit_transform, predict_proba, and score are wrapped. Each opens a named scope around the call.
  • All other attribute access delegates directly to the underlying estimator. hasattr, isinstance, and pickling work normally.
  • For Pipeline, each step is wrapped recursively so per-step scopes appear as children of the pipeline’s top-level scope.

Examples

Single estimator

Pipeline

Combined with ci.scope

Version support

Requires scikit-learn >= 1.3, the floor declared by the cirron-sdk[sklearn] extra. The proxy works with the classic estimator API (fit / predict / transform / fit_transform / predict_proba / score) and with sklearn.pipeline.Pipeline. The newer set_output API is orthogonal; wrapping does not interfere with configured output transforms.

Why it’s opt-in

sklearn has no callback or hook API comparable to Keras callbacks or HuggingFace’s TrainerCallback. Auto-wrapping every BaseEstimator subclass would be invasive and prone to breaking user code. Explicit ci.wrap(estimator) is the least-surprise approach.

ci.scope

The primitive wrap builds on; use directly for non-sklearn code.

Profiling guide

Narrative walk-through of training instrumentation.