MetaEstimatorMixin#
- класс sklearn.base.MetaEstimatorMixin[источник]#
Миксин-класс для всех мета-оценщиков в scikit-learn.
Этот миксин пуст и существует только для указания, что оценщик является мета-оценщиком.
Изменено в версии 1.6: The
_required_parametersтеперь удален и не нужен, поскольку тесты переработаны и больше не используют это.Примеры
>>> from sklearn.base import MetaEstimatorMixin >>> from sklearn.datasets import load_iris >>> from sklearn.linear_model import LogisticRegression >>> class MyEstimator(MetaEstimatorMixin): ... def __init__(self, *, estimator=None): ... self.estimator = estimator ... def fit(self, X, y=None): ... if self.estimator is None: ... self.estimator_ = LogisticRegression() ... else: ... self.estimator_ = self.estimator ... return self >>> X, y = load_iris(return_X_y=True) >>> estimator = MyEstimator().fit(X, y) >>> estimator.estimator_ LogisticRegression()