
    -im                        S r SSKrSSKJrJr  SSKrSSKJr  SSK	J
r
  SSKJrJr  SSKJr  S	S
KJrJr  S rSS.S jr\" S/\" \SS	SS9/S.SS9S%S j5       r " S S\5      r\" S/S/\" \S	SSS9/S.SS9S&S j5       r\" SS/0SS9SSS.S j5       r " S  S!\5      r\" SS/0SS9SS.S" j5       r " S# S$\5      rg)'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                   [        U R                  5      S:X  aU  U R                  S   S:X  aB  U(       d  X R                  5       -
  n [        R                  " U S-  R                  5       5      S4$ U R                  S   n[        XUS9n[        XS9n[        R                  " [        R                  " U5      5      U-  nSU-
  U-  nUR                  SSUS-   2==   XF-  -  ss'   Xt4$ )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           X/var/www/html/venv/lib/python3.13/site-packages/sklearn/covariance/_shrunk_covariance.py_ledoit_wolfr%      s     177|qQWWQZ1_FFHA}}ad[[]+S00J &	zI #1FG	!	"Z	/B	/W,JOO%zA~%&).8&      Fr   c                   [        U R                  5      S:X  aU  U R                  S   S:X  aB  U(       d  X R                  5       -
  n [        R                  " U S-  R                  5       5      S4$ U R                  u  p#[        XS9n[        R                  " US-  5      n[        R                  " U5      U-  nUS-  nXW-   nUS-   XWU-  -
  -  n	U	S:X  a  SO[        X-  S5      n
SU
-
  U-  nUR                  SSUS-   2==   X-  -  ss'   X4$ )aI  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    177|qQWWQZ1_FFHA}}ad[[]+S00GGI"1FG GGGQJE	'	Z	'BQJ 
Cq=U*%<<
=CaxSC%8I 	/W,JOO%zA~%&).8&  r&   z
array-likebothclosed)r!   r    Tprefer_skip_nested_validationc           	      .   [        U SS9n U R                  S   nSU-
  U -  n[        R                  " U SSS9U-  n[        R                  " U[        [        UR                  U R                  5      5      S9nX1U-  [        R                  " U5      -  -  nU$ )aH  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.739, 0.254],
       [0.254, 0.411]])
T)allow_ndr   )axis1axis2axis)	r   r   r   r   expand_dimstuplerangendimeye)r!   r    r   r#   r"   s        r$   shrunk_covariancerA   f   s    \ 'D1Gr"J	/W,J	'2	.	;B	uRWWgll'C!D	EBb.266*#555Jr&   c            	          ^  \ rS rSr% Sr0 \R                  ES\" \SSSS9/0Er\	\
S'   S	S
SS.U 4S jjr\" S	S9SS j5       rSrU =r$ )ShrunkCovariance   a	  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_constraintsTF皙?)store_precisionr   r    c                ,   > [         TU ]  XS9  X0l        g N)rG   r   )super__init__r    )selfrG   r   r    	__class__s       r$   rK   ShrunkCovariance.__init__   s    + 	 	
 #r&   r2   c                 .   [        X5      nU R                  (       a)  [        R                  " UR                  S   5      U l        OUR                  S5      U l        [        XR                  S9n[        X0R                  5      nU R                  U5        U $ )aa  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   rA   r    _set_covariance)rL   r   y
covariances       r$   fitShrunkCovariance.fit   sq    $ $" XXaggaj1DNVVAYDN)!=Q=QR
&z>>B
Z(r&   )rQ   r    N)__name__
__module____qualname____firstlineno____doc__r   rE   r   r   dict__annotations__rK   r   rU   __static_attributes____classcell__rM   s   @r$   rC   rC      sl    Qf$

4
4$htQ&9:$D 
 +/QT # # 5 6r&   rC   booleanleft)r   r   r     c                    [        U 5      n [        U R                  5      S:X  a  U R                  S   S:X  a  gU R                  S:X  a  [        R
                  " U S5      n U R                  S   S:X  a  [        R                  " S5        U R                  u  p4U(       d  X R                  S5      -
  n [        XB-  5      nU S-  n[        R                  " USS9U-  n[        R                  " U5      U-  nSn	Sn
[        U5       GHe  n[        U5       H  n[        X+-  X+S-   -  5      n[        X,-  X,S-   -  5      nU	[        R                  " [        R                  " UR                  U   USS2U4   5      5      -  n	U
[        R                  " [        R                  " U R                  U   U SS2U4   5      S-  5      -  n
M     [        X+-  X+S-   -  5      nU	[        R                  " [        R                  " UR                  U   USS2X%-  S24   5      5      -  n	U
[        R                  " [        R                  " U R                  U   U SS2X%-  S24   5      S-  5      -  n
GMh     [        U5       H  n[        X,-  X,S-   -  5      nU	[        R                  " [        R                  " UR                  X%-  S USS2U4   5      5      -  n	U
[        R                  " [        R                  " U R                  X%-  S U SS2U4   5      S-  5      -  n
M     U
[        R                  " [        R                  " U R                  X%-  S U SS2X%-  S24   5      S-  5      -  n
XS-  -  n
U	[        R                  " [        R                  " UR                  X%-  S USS2X%-  S24   5      5      -  n	S	XC-  -  X-  U
-
  -  nU
S
U-  UR                  5       -  -
  XHS-  -  -   nUU-  n[        UU5      nUS:X  a  SnU$ UU-  nU$ )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   r6   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
177|qQWWQZ1_vv{JJq'"wwqzQP	
 GGI q	M :*+H	
ABFF2A&2M			+BEF8_xA1u)=>D1u)=>DRVVBFF244:r!T'{;<<EbffRVVACCIqDz:a?@@F	 !
 Z^Zq5%9:rttDz2a1F1H.H+IJKK"&&D	1Q
0E0G-G+HIQNOO  8_Z^Zq5%9:rttJ$9$;<bDkJKK"&&J$9$; <a4jIQNOO  bff
qss:(*+Qq*2G2I/I-JKqP F lF	RVV
rttJ)+,bJ4I4K1K.LM E *()U->-GHDS2X 1 1 333jq56HHE	ZE tUDQYI %)5LIr&   r   r   c                f    [        UUSS9R                  U 5      nUR                  UR                  4$ )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 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   rG   )
LedoitWolfrU   covariance_
shrinkage_)r   r   r   	estimators       r$   ledoit_wolfr}     s?    n ' 
c!f	    )"6"666r&   c            	          ^  \ rS rSr% Sr0 \R                  ES\" \SSSS9/0Er\	\
S'   S	S
SS.U 4S jjr\" S	S9SS j5       rSrU =r$ )ry   i  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`
and :ref:`sphx_glr_auto_examples_covariance_plot_lw_vs_oas.py`
for more detailed examples.
r   r   Nrc   r0   rE   TFrd   )rG   r   r   c                ,   > [         TU ]  XS9  X0l        g rI   )rJ   rK   r   )rL   rG   r   r   rM   s       r$   rK   LedoitWolf.__init__A  s    + 	 	
 %r&   r2   c                 0   [        X5      nU R                  (       a)  [        R                  " UR                  S   5      U l        OUR                  S5      U l        [        XR
                  -
  SU R                  S9u  p4X@l	        U R                  U5        U $ )al  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   rP   r   rQ   r   r%   r   r{   rR   rL   r   rS   rT   r    s        r$   rU   LedoitWolf.fitG  sw    & $"XXaggaj1DNVVAYDN ,!

 $Z(r&   )r   rQ   r{   rW   )rX   rY   rZ   r[   r\   r   rE   r   r   r]   r^   rK   r   rU   r_   r`   ra   s   @r$   ry   ry     sl    fP$

4
4$x!T&AB$D 
 +/RV % % 5 6r&   ry   c                b    [        US9R                  U 5      nUR                  UR                  4$ )aJ  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   )OASrU   rz   r{   )r   r   r|   s      r$   oasr   i  s7    B '	c!f    )"6"666r&   c                   4    \ rS rSrSr\" SS9SS j5       rSrg)	r   i  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`
and :ref:`sphx_glr_auto_examples_covariance_plot_lw_vs_oas.py`
for more detailed examples.
Tr2   Nc                    [        X5      nU R                  (       a)  [        R                  " UR                  S   5      U l        OUR                  S5      U l        [        XR
                  -
  SS9u  p4X@l        U R                  U5        U $ )ax  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   rP   r   rQ   r   r.   r{   rR   r   s        r$   rU   OAS.fit  sn    " $" XXaggaj1DNVVAYDN $Q%7 N
#Z(r&   )rQ   r{   rW   )rX   rY   rZ   r[   r\   r   rU   r_    r&   r$   r   r     s"    fP 5 6r&   r   )rF   )Frd   )r\   rg   numbersr   r   numpyr   baser   utilsr   utils._param_validationr   r	   utils.validationr
    r   r   r%   r.   rA   rC   r   r}   ry   r   r   r   r&   r$   <module>r      s:    "    ? , 7!*  % 0!p  >tQ&9: #'//d|* |D ^%;!T&AB
 #'ggT <."' ', 97	97xR$ Rl <."' $ @7	@7FF
 Fr&   