Implementation:Scikit learn Scikit learn FrozenEstimator
| Knowledge Sources | |
|---|---|
| Domains | Machine Learning, Meta-Estimators |
| Last Updated | 2026-02-08 15:00 GMT |
Overview
Concrete tool for wrapping a fitted estimator to prevent re-fitting, provided by scikit-learn.
Description
The FrozenEstimator class wraps a fitted estimator and freezes it so that calling fit on it has no effect. Methods like fit_predict and fit_transform are also disabled, while all other methods are delegated to the original estimator. This is useful when you have a pre-trained model as a step in a pipeline and want pipeline.fit to skip re-fitting that step.
Usage
Use this when you have a pre-trained or pre-fitted estimator that should be used as-is within a pipeline, without being re-fitted during pipeline training.
Code Reference
Source Location
- Repository: scikit-learn
- File: sklearn/frozen/_frozen.py
Signature
class FrozenEstimator(BaseEstimator):
def __init__(self, estimator):
Import
from sklearn.frozen import FrozenEstimator
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| estimator | estimator | Yes | The fitted estimator to be kept frozen |
Outputs
| Name | Type | Description |
|---|---|---|
| predictions | ndarray | Predictions delegated to the wrapped estimator's predict method |
| transformed | ndarray | Transformations delegated to the wrapped estimator's transform method |
Usage Examples
Basic Usage
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, does not re-fit
predictions = frozen_clf.predict(X) # Delegated to clf.predict