FrozenEstimator#
- class sklearn.frozen.FrozenEstimator(estimator)[source]#
Estimator that wraps a fitted estimator to prevent re-fitting.
This meta-estimator takes an estimator and freezes it, in the sense that calling
fit
on it has no effect.fit_predict
andfit_transform
are also disabled. All other methods are delegated to the original estimator and original estimator’s attributes are accessible as well.This is particularly useful when you have a fitted or a pre-trained model as a transformer in a pipeline, and you’d like
pipeline.fit
to have no effect on this step.- Parameters:
- estimatorestimator
The estimator which is to be kept frozen.
See also
None
No similar entry in the scikit-learn documentation.
Examples
>>> from sklearn.datasets import make_classification >>> from sklearn.frozen import FrozenEstimator >>> from sklearn.linear_model import LogisticRegression >>> X, y = make_classification(random_state=0) >>> clf = LogisticRegression(random_state=0).fit(X, y) >>> frozen_clf = FrozenEstimator(clf) >>> frozen_clf.fit(X, y) # No-op FrozenEstimator(estimator=LogisticRegression(random_state=0)) >>> frozen_clf.predict(X) # Predictions from `clf.predict` array(...)
- fit(X, y, *args, **kwargs)[source]#
No-op.
As a frozen estimator, calling
fit
has no effect.- Parameters:
- Xobject
Ignored.
- yobject
Ignored.
- *argstuple
Additional positional arguments. Ignored, but present for API compatibility with
self.estimator
.- **kwargsdict
Additional keyword arguments. Ignored, but present for API compatibility with
self.estimator
.
- Returns:
- selfobject
Returns the instance itself.
- get_metadata_routing()[source]#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequest
encapsulating routing information.
Gallery examples#
Probability Calibration for 3-class classification
Post-tuning the decision threshold for cost-sensitive learning