FrozenEstimator#
- class sklearn.frozen.FrozenEstimator(estimator)[source]#
包装已拟合估算器以防止重新拟合的估算器。
此元估计器接受一个估计器并将其“冻结”,这意味着对其调用
fit不会产生任何效果。fit_predict和fit_transform也被禁用。所有其他方法都委托给原始估计器,并且原始估计器的属性也可以访问。当您在管道中将一个已拟合或预训练的模型作为转换器时,并且希望
pipeline.fit对此步骤没有影响时,这特别有用。- 参数:
- estimatorestimator
要保持冻结的估计器。
另请参阅
Nonescikit-learn 文档中没有类似的条目。
示例
>>> 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]#
空操作。
作为冻结的估计器,调用
fit没有效果。- 参数:
- Xobject
忽略。
- yobject
忽略。
- *argstuple
额外的定位参数。被忽略,但为了与
self.estimator的 API 兼容性而存在。- **kwargsdict
额外的关键字参数。被忽略,但为了与
self.estimator的 API 兼容性而存在。
- 返回:
- selfobject
返回实例本身。
- get_metadata_routing()[source]#
获取此对象的元数据路由。
请查阅 用户指南,了解路由机制如何工作。
- 返回:
- routingMetadataRequest
封装路由信息的
MetadataRequest。