
    0Phjm              
          d Z ddlZddlmZmZ ddlZddlmZ ddl	m
Z
 ddlmZmZ ddlmZ d	d
lmZmZ d ZdddZ edg eedd	d          gdd          d&d            Z G d de          Z edgdg eed	dd          gdd          d'd            Z eddgid          dddd             Z G d! d"e          Z eddgid          ddd#            Z G d$ d%e          ZdS )(z
Covariance estimators using shrinkage.

Shrinkage corresponds to regularising `cov` using a convex combination:
shrunk_cov = (1-shrinkage)*cov + shrinkage*structured_estimate.

    N)IntegralReal   )_fit_context)check_array)Intervalvalidate_params)validate_data   )EmpiricalCovarianceempirical_covariancec                   t          | j                  dk    rU| j        d         dk    rD|s| |                                 z
  } t          j        | dz                                            dfS | j        d         }t          | ||          }t          | |          }t          j        t          j        |                    |z  }d|z
  |z  }|j	        dd|dz   xx         ||z  z  cc<   ||fS )z2Estimate the shrunk Ledoit-Wolf covariance matrix.r   r           assume_centered
block_sizer         ?N)
lenshapemeannp
atleast_2dledoit_wolf_shrinkager   sumtraceflat)Xr   r   
n_features	shrinkageemp_covmu
shrunk_covs           e/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sklearn/covariance/_shrunk_covariance.py_ledoit_wolfr%      s    17||qQWQZ1__ 	AFFHHA}ad[[]]++S00J &	?z  I #1oFFFG	!!	"	"Z	/B	/W,JO%%zA~%&&&)b.8&&&y      Fr   c                (   t          | j                  dk    rU| j        d         dk    rD|s| |                                 z
  } t          j        | dz                                            dfS | j        \  }}t          | |          }t          j        |dz            }t          j        |          |z  }|dz  }||z   }|dz   |||z  z
  z  }	|	dk    rdnt          ||	z  d          }
d|
z
  |z  }|j        dd|dz   xx         |
|z  z  cc<   ||
fS )aa  Estimate covariance with the Oracle Approximating Shrinkage algorithm.

    The formulation is based on [1]_.
    [1] "Shrinkage algorithms for MMSE covariance estimation.",
        Chen, Y., Wiesel, A., Eldar, Y. C., & Hero, A. O.
        IEEE Transactions on Signal Processing, 58(10), 5016-5029, 2010.
        https://arxiv.org/pdf/0907.4698.pdf
    r   r   r   r   r   r   N)	r   r   r   r   r   r   r   minr   )r   r   	n_samplesr   r!   alphar"   
mu_squarednumdenr    r#   s               r$   _oasr.   .   s<    17||qQWQZ1__ 	AFFHHA}ad[[]]++S00GIz"1oFFFG GGQJE	'		Z	'BQJ *
Cq=UZ*%<<
=CaxxSsC%8%8I 	/W,JO%%zA~%&&&)b.8&&&y  r&   z
array-likebothclosed)r!   r    Tprefer_skip_nested_validation皙?c           	      6   t          | d          } | j        d         }d|z
  | z  }t          j        | dd          |z  }t          j        |t          t          |j        | j                                      }|||z  t          j        |          z  z  }|S )a  Calculate covariance matrices shrunk on the diagonal.

    Read more in the :ref:`User Guide <shrunk_covariance>`.

    Parameters
    ----------
    emp_cov : array-like of shape (..., n_features, n_features)
        Covariance matrices to be shrunk, at least 2D ndarray.

    shrinkage : float, default=0.1
        Coefficient in the convex combination used for the computation
        of the shrunk estimate. Range is [0, 1].

    Returns
    -------
    shrunk_cov : ndarray of shape (..., n_features, n_features)
        Shrunk covariance matrices.

    Notes
    -----
    The regularized (shrunk) covariance is given by::

        (1 - shrinkage) * cov + shrinkage * mu * np.identity(n_features)

    where `mu = trace(cov) / n_features`.

    Examples
    --------
    >>> import numpy as np
    >>> from sklearn.datasets import make_gaussian_quantiles
    >>> from sklearn.covariance import empirical_covariance, shrunk_covariance
    >>> real_cov = np.array([[.8, .3], [.3, .4]])
    >>> rng = np.random.RandomState(0)
    >>> X = rng.multivariate_normal(mean=[0, 0], cov=real_cov, size=500)
    >>> shrunk_covariance(empirical_covariance(X))
    array([[0.73..., 0.25...],
           [0.25..., 0.41...]])
    T)allow_ndr   )axis1axis2axis)	r   r   r   r   expand_dimstuplerangendimeye)r!   r    r   r#   r"   s        r$   shrunk_covariancerB   f   s    \ 'D111Gr"J	/W,J	'2	.	.	.	;B	uRWgl'C'C!D!D	E	E	EB)b.26*#5#555Jr&   c                        e Zd ZU dZi ej        d eeddd          giZee	d<   dd	d
d fd
Z
 ed          dd            Z xZS )ShrunkCovariancea
  Covariance estimator with shrinkage.

    Read more in the :ref:`User Guide <shrunk_covariance>`.

    Parameters
    ----------
    store_precision : bool, default=True
        Specify if the estimated precision is stored.

    assume_centered : bool, default=False
        If True, data will not be centered before computation.
        Useful when working with data whose mean is almost, but not exactly
        zero.
        If False, data will be centered before computation.

    shrinkage : float, default=0.1
        Coefficient in the convex combination used for the computation
        of the shrunk estimate. Range is [0, 1].

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

    location_ : ndarray of shape (n_features,)
        Estimated location, i.e. the estimated mean.

    precision_ : ndarray of shape (n_features, n_features)
        Estimated pseudo inverse matrix.
        (stored only if store_precision is True)

    n_features_in_ : int
        Number of features seen during :term:`fit`.

        .. versionadded:: 0.24

    feature_names_in_ : ndarray of shape (`n_features_in_`,)
        Names of features seen during :term:`fit`. Defined only when `X`
        has feature names that are all strings.

        .. versionadded:: 1.0

    See Also
    --------
    EllipticEnvelope : An object for detecting outliers in
        a Gaussian distributed dataset.
    EmpiricalCovariance : Maximum likelihood covariance estimator.
    GraphicalLasso : Sparse inverse covariance estimation
        with an l1-penalized estimator.
    GraphicalLassoCV : Sparse inverse covariance with cross-validated
        choice of the l1 penalty.
    LedoitWolf : LedoitWolf Estimator.
    MinCovDet : Minimum Covariance Determinant
        (robust estimator of covariance).
    OAS : Oracle Approximating Shrinkage Estimator.

    Notes
    -----
    The regularized covariance is given by:

    (1 - shrinkage) * cov + shrinkage * mu * np.identity(n_features)

    where mu = trace(cov) / n_features

    Examples
    --------
    >>> import numpy as np
    >>> from sklearn.covariance import ShrunkCovariance
    >>> from sklearn.datasets import make_gaussian_quantiles
    >>> real_cov = np.array([[.8, .3],
    ...                      [.3, .4]])
    >>> rng = np.random.RandomState(0)
    >>> X = rng.multivariate_normal(mean=[0, 0],
    ...                                   cov=real_cov,
    ...                                   size=500)
    >>> cov = ShrunkCovariance().fit(X)
    >>> cov.covariance_
    array([[0.7387..., 0.2536...],
           [0.2536..., 0.4110...]])
    >>> cov.location_
    array([0.0622..., 0.0193...])
    r    r   r   r/   r0   _parameter_constraintsTFr4   )store_precisionr   r    c                \    t                                          ||           || _        d S N)rF   r   )super__init__r    )selfrF   r   r    	__class__s       r$   rJ   zShrunkCovariance.__init__   s6    +_ 	 	
 	
 	
 #r&   r2   Nc                 2   t          | |          }| j        r%t          j        |j        d                   | _        n|                    d          | _        t          || j                  }t          || j	                  }| 
                    |           | S )a  Fit the shrunk covariance model to X.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            Training data, where `n_samples` is the number of samples
            and `n_features` is the number of features.

        y : Ignored
            Not used, present for API consistency by convention.

        Returns
        -------
        self : object
            Returns the instance itself.
        r   r   r   )r
   r   r   zerosr   	location_r   r   rB   r    _set_covariance)rK   r   y
covariances       r$   fitzShrunkCovariance.fit   s    $ $""  	'Xagaj11DNNVVAYYDN)!T=QRRR
&z4>BB
Z(((r&   N)__name__
__module____qualname____doc__r   rE   r   r   dict__annotations__rJ   r   rS   __classcell__rL   s   @r$   rD   rD      s         Q Qf$

4$hhtQ&999:$ $D   
 +/QT # # # # # # # \555   65    r&   rD   booleanleft)r   r   r     c                 4   t          |           } t          | j                  dk    r| j        d         dk    rdS | j        dk    rt	          j        | d          } | j        d         dk    rt          j        d           | j        \  }}|s| |                     d          z
  } t          ||z            }| dz  }t	          j
        |d          |z  }t	          j
        |          |z  }d}	d}
t          |          D ]l}t          |          D ]}t          ||z  ||dz   z            }t          ||z  ||dz   z            }|	t	          j
        t	          j        |j        |         |dd|f                             z  }	|
t	          j
        t	          j        | j        |         | dd|f                   dz            z  }
t          ||z  ||dz   z            }|	t	          j
        t	          j        |j        |         |dd||z  df                             z  }	|
t	          j
        t	          j        | j        |         | dd||z  df                   dz            z  }
nt          |          D ]}t          ||z  ||dz   z            }|	t	          j
        t	          j        |j        ||z  d         |dd|f                             z  }	|
t	          j
        t	          j        | j        ||z  d         | dd|f                   dz            z  }
|
t	          j
        t	          j        | j        ||z  d         | dd||z  df                   dz            z  }
|
|dz  z  }
|	t	          j
        t	          j        |j        ||z  d         |dd||z  df                             z  }	d	||z  z  |	|z  |
z
  z  }|
d
|z  |
                                z  z
  ||dz  z  z   }||z  }t          ||          }|dk    rdn||z  }|S )a\  Estimate the shrunk Ledoit-Wolf covariance matrix.

    Read more in the :ref:`User Guide <shrunk_covariance>`.

    Parameters
    ----------
    X : array-like of shape (n_samples, n_features)
        Data from which to compute the Ledoit-Wolf shrunk covariance shrinkage.

    assume_centered : bool, default=False
        If True, data will not be centered before computation.
        Useful to work with data whose mean is significantly equal to
        zero but is not exactly zero.
        If False, data will be centered before computation.

    block_size : int, default=1000
        Size of blocks into which the covariance matrix will be split.

    Returns
    -------
    shrinkage : float
        Coefficient in the convex combination used for the computation
        of the shrunk estimate.

    Notes
    -----
    The regularized (shrunk) covariance is:

    (1 - shrinkage) * cov + shrinkage * mu * np.identity(n_features)

    where mu = trace(cov) / n_features

    Examples
    --------
    >>> import numpy as np
    >>> from sklearn.covariance import ledoit_wolf_shrinkage
    >>> real_cov = np.array([[.4, .2], [.2, .8]])
    >>> rng = np.random.RandomState(0)
    >>> X = rng.multivariate_normal(mean=[0, 0], cov=real_cov, size=50)
    >>> shrinkage_coefficient = ledoit_wolf_shrinkage(X)
    >>> shrinkage_coefficient
    np.float64(0.23...)
    r   r   r   )r   r7   r   zBOnly one sample available. You may want to reshape your data arrayr;   Nr   g       @)r   r   r   r@   r   reshapewarningswarnr   intr   r?   slicedotTr(   )r   r   r   r)   r   n_splitsX2emp_cov_tracer"   beta_delta_ijrowscolsbetadeltar    s                     r$   r   r   !  s[   h 	AA
17||qQWQZ1__sv{{Jq'""wqzQP	
 	
 	
 GIz  q		M :
*++H	
ABF2A&&&2M				+BEF8__ P Px 	A 	AAaq1u)=>>Daq1u)=>>DRVBF24:r!!!T'{;;<<<EbfRVACIqDz::a?@@@FFZ!^Z1q5%9::rtDz2aaah1F1H1H.H+IJJKKK"&D	1QQQ
X0E0G0G-G+HIIQNOOO8__ P PZ!^Z1q5%9::rtJ$9$;$;<bDkJJKKK"&J$9$;$; <a4jIIQNOOO
bf
qs:(**+Qqqq*x2G2I2I/I-JKKqP  F ilF	RV
rtJ)++,bJ4I4K4K1K.LMM  E *y()UY->-GHDS2X 1 1 3 333j2q56HHE	ZE tUDQYYD5LIr&   r   r   c                h    t          ||d                              |           }|j        |j        fS )a1  Estimate the shrunk Ledoit-Wolf covariance matrix.

    Read more in the :ref:`User Guide <shrunk_covariance>`.

    Parameters
    ----------
    X : array-like of shape (n_samples, n_features)
        Data from which to compute the covariance estimate.

    assume_centered : bool, default=False
        If True, data will not be centered before computation.
        Useful to work with data whose mean is significantly equal to
        zero but is not exactly zero.
        If False, data will be centered before computation.

    block_size : int, default=1000
        Size of blocks into which the covariance matrix will be split.
        This is purely a memory optimization and does not affect results.

    Returns
    -------
    shrunk_cov : ndarray of shape (n_features, n_features)
        Shrunk covariance.

    shrinkage : float
        Coefficient in the convex combination used for the computation
        of the shrunk estimate.

    Notes
    -----
    The regularized (shrunk) covariance is:

    (1 - shrinkage) * cov + shrinkage * mu * np.identity(n_features)

    where mu = trace(cov) / n_features

    Examples
    --------
    >>> import numpy as np
    >>> from sklearn.covariance import empirical_covariance, ledoit_wolf
    >>> real_cov = np.array([[.4, .2], [.2, .8]])
    >>> rng = np.random.RandomState(0)
    >>> X = rng.multivariate_normal(mean=[0, 0], cov=real_cov, size=50)
    >>> covariance, shrinkage = ledoit_wolf(X)
    >>> covariance
    array([[0.44..., 0.16...],
           [0.16..., 0.80...]])
    >>> shrinkage
    np.float64(0.23...)
    F)r   r   rF   )
LedoitWolfrS   covariance_
shrinkage_)r   r   r   	estimators       r$   ledoit_wolfrx     sE    n '   
c!ff	   )"666r&   c                        e Zd ZU dZi ej        d eeddd          giZee	d<   dd	d
d fd
Z
 ed          dd            Z xZS )rt   a&  LedoitWolf Estimator.

    Ledoit-Wolf is a particular form of shrinkage, where the shrinkage
    coefficient is computed using O. Ledoit and M. Wolf's formula as
    described in "A Well-Conditioned Estimator for Large-Dimensional
    Covariance Matrices", Ledoit and Wolf, Journal of Multivariate
    Analysis, Volume 88, Issue 2, February 2004, pages 365-411.

    Read more in the :ref:`User Guide <shrunk_covariance>`.

    Parameters
    ----------
    store_precision : bool, default=True
        Specify if the estimated precision is stored.

    assume_centered : bool, default=False
        If True, data will not be centered before computation.
        Useful when working with data whose mean is almost, but not exactly
        zero.
        If False (default), data will be centered before computation.

    block_size : int, default=1000
        Size of blocks into which the covariance matrix will be split
        during its Ledoit-Wolf estimation. This is purely a memory
        optimization and does not affect results.

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

    location_ : ndarray of shape (n_features,)
        Estimated location, i.e. the estimated mean.

    precision_ : ndarray of shape (n_features, n_features)
        Estimated pseudo inverse matrix.
        (stored only if store_precision is True)

    shrinkage_ : float
        Coefficient in the convex combination used for the computation
        of the shrunk estimate. Range is [0, 1].

    n_features_in_ : int
        Number of features seen during :term:`fit`.

        .. versionadded:: 0.24

    feature_names_in_ : ndarray of shape (`n_features_in_`,)
        Names of features seen during :term:`fit`. Defined only when `X`
        has feature names that are all strings.

        .. versionadded:: 1.0

    See Also
    --------
    EllipticEnvelope : An object for detecting outliers in
        a Gaussian distributed dataset.
    EmpiricalCovariance : Maximum likelihood covariance estimator.
    GraphicalLasso : Sparse inverse covariance estimation
        with an l1-penalized estimator.
    GraphicalLassoCV : Sparse inverse covariance with cross-validated
        choice of the l1 penalty.
    MinCovDet : Minimum Covariance Determinant
        (robust estimator of covariance).
    OAS : Oracle Approximating Shrinkage Estimator.
    ShrunkCovariance : Covariance estimator with shrinkage.

    Notes
    -----
    The regularised covariance is:

    (1 - shrinkage) * cov + shrinkage * mu * np.identity(n_features)

    where mu = trace(cov) / n_features
    and shrinkage is given by the Ledoit and Wolf formula (see References)

    References
    ----------
    "A Well-Conditioned Estimator for Large-Dimensional Covariance Matrices",
    Ledoit and Wolf, Journal of Multivariate Analysis, Volume 88, Issue 2,
    February 2004, pages 365-411.

    Examples
    --------
    >>> import numpy as np
    >>> from sklearn.covariance import LedoitWolf
    >>> real_cov = np.array([[.4, .2],
    ...                      [.2, .8]])
    >>> np.random.seed(0)
    >>> X = np.random.multivariate_normal(mean=[0, 0],
    ...                                   cov=real_cov,
    ...                                   size=50)
    >>> cov = LedoitWolf().fit(X)
    >>> cov.covariance_
    array([[0.4406..., 0.1616...],
           [0.1616..., 0.8022...]])
    >>> cov.location_
    array([ 0.0595... , -0.0075...])

    See also :ref:`sphx_glr_auto_examples_covariance_plot_covariance_estimation.py`
    for a more detailed example.
    r   r   Nr^   r0   rE   TFr_   )rF   r   r   c                \    t                                          ||           || _        d S rH   )rI   rJ   r   )rK   rF   r   r   rL   s       r$   rJ   zLedoitWolf.__init__@  s6    +_ 	 	
 	
 	
 %r&   r2   c                 .   t          | |          }| j        r%t          j        |j        d                   | _        n|                    d          | _        t          || j        z
  d| j                  \  }}|| _	        | 
                    |           | S )a  Fit the Ledoit-Wolf shrunk covariance model to X.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            Training data, where `n_samples` is the number of samples
            and `n_features` is the number of features.
        y : Ignored
            Not used, present for API consistency by convention.

        Returns
        -------
        self : object
            Returns the instance itself.
        r   r   Tr   )r
   r   r   rN   r   rO   r   r%   r   rv   rP   rK   r   rQ   rR   r    s        r$   rS   zLedoitWolf.fitF  s    & $"" 	'Xagaj11DNNVVAYYDN ,!
 !
 !

I $Z(((r&   rT   )rU   rV   rW   rX   r   rE   r   r   rY   rZ   rJ   r   rS   r[   r\   s   @r$   rt   rt     s         e eN$

4$xx!T&AAAB$ $D   
 +/RV % % % % % % % \555   65    r&   rt   c                d    t          |                              |           }|j        |j        fS )a  Estimate covariance with the Oracle Approximating Shrinkage.

    Read more in the :ref:`User Guide <shrunk_covariance>`.

    Parameters
    ----------
    X : array-like of shape (n_samples, n_features)
        Data from which to compute the covariance estimate.

    assume_centered : bool, default=False
      If True, data will not be centered before computation.
      Useful to work with data whose mean is significantly equal to
      zero but is not exactly zero.
      If False, data will be centered before computation.

    Returns
    -------
    shrunk_cov : array-like of shape (n_features, n_features)
        Shrunk covariance.

    shrinkage : float
        Coefficient in the convex combination used for the computation
        of the shrunk estimate.

    Notes
    -----
    The regularised covariance is:

    (1 - shrinkage) * cov + shrinkage * mu * np.identity(n_features),

    where mu = trace(cov) / n_features and shrinkage is given by the OAS formula
    (see [1]_).

    The shrinkage formulation implemented here differs from Eq. 23 in [1]_. In
    the original article, formula (23) states that 2/p (p being the number of
    features) is multiplied by Trace(cov*cov) in both the numerator and
    denominator, but this operation is omitted because for a large p, the value
    of 2/p is so small that it doesn't affect the value of the estimator.

    References
    ----------
    .. [1] :arxiv:`"Shrinkage algorithms for MMSE covariance estimation.",
           Chen, Y., Wiesel, A., Eldar, Y. C., & Hero, A. O.
           IEEE Transactions on Signal Processing, 58(10), 5016-5029, 2010.
           <0907.4698>`

    Examples
    --------
    >>> import numpy as np
    >>> from sklearn.covariance import oas
    >>> rng = np.random.RandomState(0)
    >>> real_cov = [[.8, .3], [.3, .4]]
    >>> X = rng.multivariate_normal(mean=[0, 0], cov=real_cov, size=500)
    >>> shrunk_cov, shrinkage = oas(X)
    >>> shrunk_cov
    array([[0.7533..., 0.2763...],
           [0.2763..., 0.3964...]])
    >>> shrinkage
    np.float64(0.0195...)
    r   )OASrS   ru   rv   )r   r   rw   s      r$   oasr   h  s=    B '  	c!ff   )"666r&   c                   >    e Zd ZdZ ed          dd            ZdS )r~   a  Oracle Approximating Shrinkage Estimator.

    Read more in the :ref:`User Guide <shrunk_covariance>`.

    Parameters
    ----------
    store_precision : bool, default=True
        Specify if the estimated precision is stored.

    assume_centered : bool, default=False
        If True, data will not be centered before computation.
        Useful when working with data whose mean is almost, but not exactly
        zero.
        If False (default), data will be centered before computation.

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

    location_ : ndarray of shape (n_features,)
        Estimated location, i.e. the estimated mean.

    precision_ : ndarray of shape (n_features, n_features)
        Estimated pseudo inverse matrix.
        (stored only if store_precision is True)

    shrinkage_ : float
      coefficient in the convex combination used for the computation
      of the shrunk estimate. Range is [0, 1].

    n_features_in_ : int
        Number of features seen during :term:`fit`.

        .. versionadded:: 0.24

    feature_names_in_ : ndarray of shape (`n_features_in_`,)
        Names of features seen during :term:`fit`. Defined only when `X`
        has feature names that are all strings.

        .. versionadded:: 1.0

    See Also
    --------
    EllipticEnvelope : An object for detecting outliers in
        a Gaussian distributed dataset.
    EmpiricalCovariance : Maximum likelihood covariance estimator.
    GraphicalLasso : Sparse inverse covariance estimation
        with an l1-penalized estimator.
    GraphicalLassoCV : Sparse inverse covariance with cross-validated
        choice of the l1 penalty.
    LedoitWolf : LedoitWolf Estimator.
    MinCovDet : Minimum Covariance Determinant
        (robust estimator of covariance).
    ShrunkCovariance : Covariance estimator with shrinkage.

    Notes
    -----
    The regularised covariance is:

    (1 - shrinkage) * cov + shrinkage * mu * np.identity(n_features),

    where mu = trace(cov) / n_features and shrinkage is given by the OAS formula
    (see [1]_).

    The shrinkage formulation implemented here differs from Eq. 23 in [1]_. In
    the original article, formula (23) states that 2/p (p being the number of
    features) is multiplied by Trace(cov*cov) in both the numerator and
    denominator, but this operation is omitted because for a large p, the value
    of 2/p is so small that it doesn't affect the value of the estimator.

    References
    ----------
    .. [1] :arxiv:`"Shrinkage algorithms for MMSE covariance estimation.",
           Chen, Y., Wiesel, A., Eldar, Y. C., & Hero, A. O.
           IEEE Transactions on Signal Processing, 58(10), 5016-5029, 2010.
           <0907.4698>`

    Examples
    --------
    >>> import numpy as np
    >>> from sklearn.covariance import OAS
    >>> from sklearn.datasets import make_gaussian_quantiles
    >>> real_cov = np.array([[.8, .3],
    ...                      [.3, .4]])
    >>> rng = np.random.RandomState(0)
    >>> X = rng.multivariate_normal(mean=[0, 0],
    ...                             cov=real_cov,
    ...                             size=500)
    >>> oas = OAS().fit(X)
    >>> oas.covariance_
    array([[0.7533..., 0.2763...],
           [0.2763..., 0.3964...]])
    >>> oas.precision_
    array([[ 1.7833..., -1.2431... ],
           [-1.2431...,  3.3889...]])
    >>> oas.shrinkage_
    np.float64(0.0195...)

    See also :ref:`sphx_glr_auto_examples_covariance_plot_covariance_estimation.py`
    for a more detailed example.
    Tr2   Nc                 "   t          | |          }| j        r%t          j        |j        d                   | _        n|                    d          | _        t          || j        z
  d          \  }}|| _        | 	                    |           | S )a  Fit the Oracle Approximating Shrinkage covariance model to X.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            Training data, where `n_samples` is the number of samples
            and `n_features` is the number of features.
        y : Ignored
            Not used, present for API consistency by convention.

        Returns
        -------
        self : object
            Returns the instance itself.
        r   r   Tr   )
r
   r   r   rN   r   rO   r   r.   rv   rP   r|   s        r$   rS   zOAS.fit  s    " $""  	'Xagaj11DNNVVAYYDN $Q%7 N N N
I#Z(((r&   rT   )rU   rV   rW   rX   r   rS    r&   r$   r~   r~     sO        e eN \555   65  r&   r~   )r4   )Fr_   )rX   rb   numbersr   r   numpyr   baser   utilsr   utils._param_validationr   r	   utils.validationr
    r   r   r%   r.   rB   rD   r   rx   rt   r   r~   r   r&   r$   <module>r      s     " " " " " " " "                 ? ? ? ? ? ? ? ? , , , , , , 7 7 7 7 7 7 7 7! ! !*  % 0! 0! 0! 0! 0!p  >htQ&999:  #'  / / / /d| | | | |* | | |D ^%;x!T&AAAB 
 #'  g g g gT <."'   ', 97 97 97 97	 97xQ Q Q Q Q$ Q Q Qj <."'   $ @7 @7 @7 @7	 @7FE E E E E
 E E E E Er&   