<commit_before>import numpy as np
from scipy.stats import chi2
from sklearn.covariance import GraphLasso
from sklearn.utils import check_array
from sklearn.utils.validation import check_is_fitted

from ..base import AnalyzerMixin, DetectorMixin
from ..utils import assign_info_on_pandas_obj, construct_pandas_obj


class GaussianOutlierDetector(GraphLasso, AnalyzerMixin, DetectorMixin):
    """Outlier detector in Gaussian distribution.

    Parameters
    ----------
    alpha : float, default 0.01
        Regularization parameter.

    assume_centered : boolean, default False
        If True, data are not centered before computation.

    fpr : float, default 0.01
        False positive rate. Used to compute the threshold.

    max_iter : int, default 100
        Maximum number of iterations.

    tol : float, default 0.0001
        Tolerance to declare convergence. If the dual gap goes below this
        value, iterations are stopped.

    Attributes
    ----------
    covariance_ : ndarray of shape (n_features, n_features)
        Estimated covariance matrix.

    precision_ : ndarray of shape (n_features, n_features)
        Estimated pseudo inverse matrix.

    threshold_ : float
        Threshold.

    feature_wise_threshold_ : ndarray of shape (n_features,)
        Feature-wise threshold.
    """

    def __init__(
        self,                  alpha=0.01,
        assume_centered=False, fpr=0.01,
        max_iter=100,          tol=0.0001
    ):
        super().__init__(
            alpha           = alpha,
            assume_centered = assume_centered,
            max_iter        = max_iter,
            tol             = tol
        )

        self.fpr            = fpr

        self.check_params()

    def check_params(self):
        """Check validity of parameters and raise ValueError if not valid."""

        if self.alpha < 0 or 1 < self.alpha:
            raise ValueError(
                'alpha must be between 0 and 1 inclusive but was {0}'.format(
                    self.alpha
                )
            )

        if self.fpr < 0 or 1 < self.fpr:
            raise ValueError(<commit_msg>update content of docstring<commit_after>import numpy as np
from scipy.stats import chi2
from sklearn.covariance import GraphLasso
from sklearn.utils import check_array
from sklearn.utils.validation import check_is_fitted

from ..base import AnalyzerMixin, DetectorMixin
from ..utils import assign_info_on_pandas_obj, construct_pandas_obj


class GaussianOutlierDetector(GraphLasso, AnalyzerMixin, DetectorMixin):
    """Outlier detector in Gaussian distribution.

    Parameters
    ----------
    alpha : float, default 0.01
        Regularization parameter.

    assume_centered : boolean, default False
        If True, data are not centered before computation.

    fpr : float, default 0.01
        False positive rate. Used to compute the threshold.

    max_iter : int, default 100
        Maximum number of iterations.

    tol : float, default 0.0001
        Tolerance to declare convergence. If the dual gap goes below this
        value, iterations are stopped.

    Attributes
    ----------
    covariance_ : ndarray of shape (n_features, n_features)
        Estimated covariance matrix.

    precision_ : ndarray of shape (n_features, n_features)
        Estimated pseudo inverse matrix.

    threshold_ : float
        Threshold.

    feature_wise_threshold_ : ndarray of shape (n_features,)
        Feature-wise threshold.

    References
    ----------
    <NAME>, <NAME>, <NAME> and <NAME>,
    "Proximity-based anomaly detection using sparse structure learning,"
    In Proceedings of SDM'09, pp. 97 - 108, 2009.
    """

    def __init__(
        self,                  alpha=0.01,
        assume_centered=False, fpr=0.01,
        max_iter=100,          tol=0.0001
    ):
        super().__init__(
            alpha           = alpha,
            assume_centered = assume_centered,
            max_iter        = max_iter,
            tol             = tol
        )

        self.fpr            = fpr

        self.check_params()

    def check_params(self):
        """Check validity of parameters and raise ValueError if not valid."""

        if self.alpha < 0 or 1 < self.alpha:
            raise ValueError(
                'alpha must be between 0 and 1 inclusive but was {0}'.format(
                    self.alpha
                )
            )

        if self.fpr < 0 or 1 < self.fpr:
            raise ValueError(
{'fraction_non_alphanumeric': 0.0738015607580825, 'fraction_numerical': 0.01850613154960981, 'mean_word_length': 1.9827127659574468, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6877715', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1169, 'n_words': 397}