class sklearn.base.OutlierMixin[source]

Mixin class for all outlier detection estimators in scikit-learn.

This mixin defines the following functionality:

  • _estimator_type class attribute defaulting to outlier_detector;

  • fit_predict method that default to fit and predict.


>>> import numpy as np
>>> from sklearn.base import BaseEstimator, OutlierMixin
>>> class MyEstimator(OutlierMixin):
...     def fit(self, X, y=None):
...         self.is_fitted_ = True
...         return self
...     def predict(self, X):
...         return np.ones(shape=len(X))
>>> estimator = MyEstimator()
>>> X = np.array([[1, 2], [2, 3], [3, 4]])
>>> estimator.fit_predict(X)
array([1., 1., 1.])


fit_predict(X[, y])

Perform fit on X and returns labels for X.

fit_predict(X, y=None, **kwargs)[source]

Perform fit on X and returns labels for X.

Returns -1 for outliers and 1 for inliers.

X{array-like, sparse matrix} of shape (n_samples, n_features)

The input samples.


Not used, present for API consistency by convention.


Arguments to be passed to fit.

New in version 1.4.

yndarray of shape (n_samples,)

1 for inliers, -1 for outliers.