Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Scikit learn Scikit learn EllipticEnvelope

From Leeroopedia


Knowledge Sources
Domains Machine Learning, Outlier Detection
Last Updated 2026-02-08 15:00 GMT

Overview

Concrete tool for detecting outliers in a Gaussian distributed dataset using a robust covariance estimate, provided by scikit-learn.

Description

The EllipticEnvelope class fits a robust covariance estimate to the data using the Minimum Covariance Determinant (MCD) algorithm and then determines which samples are outliers. It inherits from OutlierMixin and MinCovDet, combining robust covariance estimation with outlier detection capabilities.

Usage

Use this estimator when you need to detect outliers in datasets that are approximately Gaussian distributed. It is suitable for novelty detection where the training data is not contaminated, or outlier detection where a known proportion of contamination exists.

Code Reference

Source Location

Signature

class EllipticEnvelope(OutlierMixin, MinCovDet):
    def __init__(
        self,
        *,
        store_precision=True,
        assume_centered=False,
        support_fraction=None,
        contamination=0.1,
        random_state=None,
    ):

Import

from sklearn.covariance import EllipticEnvelope

I/O Contract

Inputs

Name Type Required Description
store_precision bool No Specify if the estimated precision is stored (default True)
assume_centered bool No If True, data is assumed centered (default False)
support_fraction float No Proportion of points for support of raw MCD estimate (default None)
contamination float No Proportion of outliers in the data set (default 0.1, range (0, 0.5])
random_state int, RandomState or None No Random number generator seed (default None)

Outputs

Name Type Description
location_ ndarray of shape (n_features,) Estimated robust location
covariance_ ndarray of shape (n_features, n_features) Estimated robust covariance matrix
precision_ ndarray of shape (n_features, n_features) Estimated pseudo inverse matrix (if store_precision is True)

Usage Examples

Basic Usage

import numpy as np
from sklearn.covariance import EllipticEnvelope

# Generate normal data with outliers
X = np.random.randn(100, 2)
X[0] = [10, 10]  # add an outlier

envelope = EllipticEnvelope(contamination=0.1, random_state=0)
envelope.fit(X)
predictions = envelope.predict(X)
print(predictions)  # -1 for outliers, 1 for inliers

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment