
    -i{                     H   S r SSKrSSKJ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Jr  SS	KJr  SS
KJrJrJr  SSKJrJrJr  SSKJrJrJrJr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 jr*     S)S jr+\" S/\RX                  /\" \SSSS9S/\" \SSSS9S/S\" S15      /S/S/S/S.SS9SSSSSSS.S j5       r-\" S/S/\" \SSSS9S/\" \SSSS9S/SS/S/S/S/S/S .	SS9SSSSSSSS!.S" j5       r. " S# S$\\\'5      r/   S*S% jr0 " S& S'\\'5      r1g)+z&Orthogonal matching pursuit algorithms    N)sqrt)IntegralReal)linalg)get_lapack_funcs   )MultiOutputMixinRegressorMixin_fit_context)check_cv)Bunchas_float_arraycheck_array)Interval
StrOptionsvalidate_params)MetadataRouterMethodMapping_raise_for_params_routing_enabledprocess_routing)Paralleldelayed)validate_data   )LinearModel_pre_fitzOrthogonal matching pursuit ended prematurely due to linear dependence in the dictionary. The requested precision might not have been met.TFc           	         U(       a  U R                  S5      n O[        R                  " U 5      n [        R                  " U R                  5      R
                  n[        R                  " SU 45      u  px[        SU 45      u  n	[        R                  " U R                  U5      n
Un[        R                  " S5      nSn[        R                  " U R                  S   5      nUb  U R                  S   OUn[        R                  " X4U R                  S9nU(       a  [        R                  " U5      n [        R                  " [        R                   " [        R                  " U R                  U5      5      5      nUU:  d  U
U   S	-  U:  a   ["        R$                  " [&        [(        S	S
9  GOUS:  a  [        R                  " U SS2SU24   R                  U SS2U4   5      UUSU24'   [        R*                  " USU2SU24   UUSU24   SSSSS9  U" UUSU24   5      S	-  n[        R,                  " U SS2U4   5      S	-  U-
  nUU::  a  ["        R$                  " [&        [(        S	S
9  O[/        U5      UX4'   O [        R,                  " U SS2U4   5      US'   U" U R                  U   U R                  U   5      u  U R                  U'   U R                  U'   U
U   X   sX'   U
U'   UU   X   sX'   UU'   US-  nU	" USU2SU24   U
SU SSS9u  nnU(       a  UWSU2US-
  4'   U[        R                  " U SS2SU24   U5      -
  nUb  U" U5      S	-  U::  a  O	X:X  a  OGM9  U(       a  XSU WSS2SU24   U4$ XSU U4$ )a  Orthogonal Matching Pursuit step using the Cholesky decomposition.

Parameters
----------
X : ndarray of shape (n_samples, n_features)
    Input dictionary. Columns are assumed to have unit norm.

y : ndarray of shape (n_samples,)
    Input targets.

n_nonzero_coefs : int
    Targeted number of non-zero elements.

tol : float, default=None
    Targeted squared error, if not None overrides n_nonzero_coefs.

copy_X : bool, default=True
    Whether the design matrix X must be copied by the algorithm. A false
    value is only helpful if X is already Fortran-ordered, otherwise a
    copy is made anyway.

return_path : bool, default=False
    Whether to return every value of the nonzero coefficients along the
    forward path. Useful for cross-validation.

Returns
-------
gamma : ndarray of shape (n_nonzero_coefs,)
    Non-zero elements of the solution.

idx : ndarray of shape (n_nonzero_coefs,)
    Indices of the positions of the elements in gamma within the solution
    vector.

coef : ndarray of shape (n_features, n_nonzero_coefs)
    The first k values of column k correspond to the coefficient value
    for the active features at that step. The lower left triangle contains
    garbage. Only returned if ``return_path=True``.

n_active : int
    Number of active features at convergence.
Fnrm2swappotrsr   r   NdtypeTr   
stacklevelFtransloweroverwrite_bcheck_finiter   r   r+   r,   )copynpasfortranarrayfinfor&   epsr   get_blas_funcsr   dotTemptyarangeshape
empty_likeargmaxabswarningswarn	prematureRuntimeWarningsolve_triangularnormr   )Xyn_nonzero_coefstolcopy_Xreturn_path	min_floatr!   r"   r$   alpharesidualgamman_activeindicesmax_featuresLcoefslamvLkk_s                         L/var/www/html/venv/lib/python3.13/site-packages/sklearn/linear_model/_omp.py_cholesky_omprX   $   sp   V FF3Ka !%%I&&'7!>JD
QD1HUFF133NEHHHQKEHii
#G!$1771:oL
,-QWW=Aa 
iirvvacc8456>U3Z1_y8MM)^Ba<%'VVAa(lO,=,=qCy%IAh		!"##)8)YhY&'(IXI%& " Qx(*+,1A++a3i(A-1CiiAF$(IAh !kk!AsF),AdG"&qss8}acc#h"?Hqss3x&+Cj%/#s*1#,8I'73<A ixi("#U9H%5Tu
q -2E)8)X\)*rvva9H9ou55?tH~2c9%W Z ix(%9H9*=xGGix((22    c           	         U(       a  U R                  S5      O[        R                  " U 5      n U(       d  UR                  R                  (       d  UR                  5       n[        R
                  " U R                  5      R                  n[        R                  " SU 45      u  p[        SU 45      u  n[        R                  " [        U 5      5      nUnUnSn[        R                  " S5      nSnUb  [        U 5      OUn[        R                  " UU4U R                  S9nSUS'   U(       a  [        R                  " U5      n [        R                  " [        R                   " U5      5      nUU:  d  UU   S
-  U:  a   ["        R$                  " [&        [(        SS9  GOUS:  a  U USU24   UUSU24'   [        R*                  " USU2SU24   UUSU24   SSS	SS9  U	" UUSU24   5      S
-  nU UU4   U-
  nUU::  a   ["        R$                  " [&        [(        SS9  GO3[-        U5      UUU4'   O[-        U UU4   5      US'   U
" U U   U U   5      u  U U'   U U'   U
" U R.                  U   U R.                  U   5      u  U R.                  U'   U R.                  U'   UU   UU   sUU'   UU'   UU   UU   sUU'   UU'   US-  nU" USU2SU24   USU S	SS9u  nnU(       a  UWSU2US-
  4'   [        R0                  " U SS2SU24   U5      nUU-
  nUb3  X-  n[        R2                  " UUSU 5      nX-  n[!        U5      U::  a  OOUU:X  a  OGM  U(       a  UUSU WSS2SU24   U4$ UUSU U4$ )a  Orthogonal Matching Pursuit step on a precomputed Gram matrix.

This function uses the Cholesky decomposition method.

Parameters
----------
Gram : ndarray of shape (n_features, n_features)
    Gram matrix of the input data matrix.

Xy : ndarray of shape (n_features,)
    Input targets.

n_nonzero_coefs : int
    Targeted number of non-zero elements.

tol_0 : float, default=None
    Squared norm of y, required if tol is not None.

tol : float, default=None
    Targeted squared error, if not None overrides n_nonzero_coefs.

copy_Gram : bool, default=True
    Whether the gram matrix must be copied by the algorithm. A false
    value is only helpful if it is already Fortran-ordered, otherwise a
    copy is made anyway.

copy_Xy : bool, default=True
    Whether the covariance vector Xy must be copied by the algorithm.
    If False, it may be overwritten.

return_path : bool, default=False
    Whether to return every value of the nonzero coefficients along the
    forward path. Useful for cross-validation.

Returns
-------
gamma : ndarray of shape (n_nonzero_coefs,)
    Non-zero elements of the solution.

idx : ndarray of shape (n_nonzero_coefs,)
    Indices of the positions of the elements in gamma within the solution
    vector.

coefs : ndarray of shape (n_features, n_nonzero_coefs)
    The first k values of column k correspond to the coefficient value
    for the active features at that step. The lower left triangle contains
    garbage. Only returned if ``return_path=True``.

n_active : int
    Number of active features at convergence.
r   r    r#   r   Nr%   g      ?r.   Tr      r'   r   Fr)   r/   )r0   r1   r2   flags	writeabler3   r&   r4   r   r5   r   r9   lenr8   r;   r<   r=   r>   r?   r@   rA   rB   r   r7   r6   inner)GramXyrF   tol_0rG   	copy_Gramcopy_XyrI   rJ   r!   r"   r$   rO   rK   tol_currdeltarM   rN   rP   rQ   rR   rS   rT   rU   rV   betas                             rW   	_gram_omprh      s   z '499S>B,=,=d,CDbhh((WWY$((I&&'7$AJD
TG4HUiiD	"GEHEHHQKEH #3t9_L
,-TZZ@AAdGa 
iiu&>U3Z1_y8MM)^Ba<%)#yy.%9Ah		!"##)8)YhY&'(IXI%& " Qx(*+,1AsCx.1$CiiAF$(IAh !4S>*AdG$(hc$C!XS	(,TVVH-=tvvc{(K%x$&&+*1#,8I'73< "3H8bgAixi("#R	]$E
q -2E)8)X\)*vvd1ixi<(%0T	?HHHUD(O4EH8}# $%[ ^ gix(%9H9*=xGGgix((22rY   z
array-likeleftclosedbooleanauto)rD   rE   rF   rG   
precomputerH   rI   return_n_iterprefer_skip_nested_validation)rF   rG   rn   rH   rI   ro   c                |   [        U SUS9n SnUR                  S:X  a  UR                  SS5      n[        U5      nUR                  S   S:  a  SnUc(  Uc%  [	        [        SU R                  S   -  5      S5      nUc  X R                  S   :  a  [        S	5      eUS
:X  a  U R                  S   U R                  S   :  nU(       a  [        R                  " U R                  U 5      n[        R                  " U5      n[        R                  " U R                  U5      n	Ub  [        R                  " US-  SS9n
OSn
[        UU	UUU
USUS9$ U(       aA  [        R                  " U R                  S   UR                  S   U R                  S   45      nO2[        R                  " U R                  S   UR                  S   45      n/ n[        UR                  S   5       H  n[        XSS2U4   X#XVS9nU(       aR  Uu  nnnnUSS2SS2S[!        U5      24   n[#        UR                  5       H  u  nnUSUS-    UUSUS-    UU4'   M     OUu  nnnUUUU4'   UR%                  U5        M     UR                  S   S:X  a  US   nU(       a  [        R&                  " U5      U4$ [        R&                  " U5      $ )aG  Orthogonal Matching Pursuit (OMP).

Solves n_targets Orthogonal Matching Pursuit problems.
An instance of the problem has the form:

When parametrized by the number of non-zero coefficients using
`n_nonzero_coefs`:
argmin ||y - X\gamma||^2 subject to ||\gamma||_0 <= n_{nonzero coefs}

When parametrized by error using the parameter `tol`:
argmin ||\gamma||_0 subject to ||y - X\gamma||^2 <= tol

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

Parameters
----------
X : array-like of shape (n_samples, n_features)
    Input data. Columns are assumed to have unit norm.

y : ndarray of shape (n_samples,) or (n_samples, n_targets)
    Input targets.

n_nonzero_coefs : int, default=None
    Desired number of non-zero entries in the solution. If None (by
    default) this value is set to 10% of n_features.

tol : float, default=None
    Maximum squared norm of the residual. If not None, overrides n_nonzero_coefs.

precompute : 'auto' or bool, default=False
    Whether to perform precomputations. Improves performance when n_targets
    or n_samples is very large.

copy_X : bool, default=True
    Whether the design matrix X must be copied by the algorithm. A false
    value is only helpful if X is already Fortran-ordered, otherwise a
    copy is made anyway.

return_path : bool, default=False
    Whether to return every value of the nonzero coefficients along the
    forward path. Useful for cross-validation.

return_n_iter : bool, default=False
    Whether or not to return the number of iterations.

Returns
-------
coef : ndarray of shape (n_features,) or (n_features, n_targets)
    Coefficients of the OMP solution. If `return_path=True`, this contains
    the whole coefficient path. In this case its shape is
    (n_features, n_features) or (n_features, n_targets, n_features) and
    iterating over the last axis generates coefficients in increasing order
    of active features.

n_iters : array-like or int
    Number of active features across every target. Returned only if
    `return_n_iter` is set to True.

See Also
--------
OrthogonalMatchingPursuit : Orthogonal Matching Pursuit model.
orthogonal_mp_gram : Solve OMP problems using Gram matrix and the product X.T * y.
lars_path : Compute Least Angle Regression or Lasso path using LARS algorithm.
sklearn.decomposition.sparse_encode : Sparse coding.

Notes
-----
Orthogonal matching pursuit was introduced in S. Mallat, Z. Zhang,
Matching pursuits with time-frequency dictionaries, IEEE Transactions on
Signal Processing, Vol. 41, No. 12. (December 1993), pp. 3397-3415.
(https://www.di.ens.fr/~mallat/papiers/MallatPursuit93.pdf)

This implementation is based on Rubinstein, R., Zibulevsky, M. and Elad,
M., Efficient Implementation of the K-SVD Algorithm using Batch Orthogonal
Matching Pursuit Technical Report - CS Technion, April 2008.
https://www.cs.technion.ac.il/~ronrubin/Publications/KSVD-OMP-v2.pdf

Examples
--------
>>> from sklearn.datasets import make_regression
>>> from sklearn.linear_model import orthogonal_mp
>>> X, y = make_regression(noise=4, random_state=0)
>>> coef = orthogonal_mp(X, y)
>>> coef.shape
(100,)
>>> X[:1,] @ coef
array([-78.68])
r   orderr0   Fr   TN皙?>The number of atoms cannot be more than the number of featuresrm   r   r   axis)rF   rG   norms_squaredrc   rd   rI   )rH   rI   )r   ndimreshaper:   maxint
ValueErrorr1   r6   r7   r2   sumorthogonal_mp_gramzerosrangerX   r^   	enumerateappendsqueeze)rD   rE   rF   rG   rn   rH   rI   ro   Gra   rz   coefn_iterskoutrV   idxrR   n_iterrN   xs                        rW   orthogonal_mpr   "  s   ` 	ASv.AFvv{IIb!AAwwqzA~3; c#
"23Q7
{3L
 	
 VWWQZ!''!*,
FF133Na VVACC^?FFAqD2M M!+'#	
 		
 xxQWWQZ<=xxQWWQZ01G1771:AwV
 $'!AsE61jCj()D(1!9:>X\9JS8a<(!X56  2 !NAsFDaLv  	wwqzQ!*zz$((zz$rY   neither)	r`   ra   rF   rG   rz   rc   rd   rI   ro   )rF   rG   rz   rc   rd   rI   ro   c                2   [        U SUS9n [        R                  " U5      nUR                  S:  a  UR                  S   S:  a  SnUR                  S:X  a  USS2[        R
                  4   nUb  U/nU(       d  UR                  R                  (       d  UR                  5       nUc  Uc  [        S[        U 5      -  5      nUb  Uc  [        S5      eUb  US:  a  [        S	5      eUc  US::  a  [        S
5      eUc  U[        U 5      :  a  [        S5      eU(       aB  [        R                  " [        U 5      UR                  S   [        U 5      4U R                  S9n	O7[        R                  " [        U 5      UR                  S   4U R                  S9n	/ n
[        UR                  S   5       H  n[        U USS2U4   UUb  XK   OSUUSUS9nU(       aP  Uu  pnnU	SS2SS2S[        U5      24   n	[!        UR"                  5       H  u  nnUSUS-    XSUS-    UU4'   M     OUu  nnnUXU4'   U
R%                  U5        M     UR                  S   S:X  a  U
S   n
U(       a  [        R&                  " U	5      U
4$ [        R&                  " U	5      $ )aW  Gram Orthogonal Matching Pursuit (OMP).

Solves n_targets Orthogonal Matching Pursuit problems using only
the Gram matrix X.T * X and the product X.T * y.

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

Parameters
----------
Gram : array-like of shape (n_features, n_features)
    Gram matrix of the input data: `X.T * X`.

Xy : array-like of shape (n_features,) or (n_features, n_targets)
    Input targets multiplied by `X`: `X.T * y`.

n_nonzero_coefs : int, default=None
    Desired number of non-zero entries in the solution. If `None` (by
    default) this value is set to 10% of n_features.

tol : float, default=None
    Maximum squared norm of the residual. If not `None`,
    overrides `n_nonzero_coefs`.

norms_squared : array-like of shape (n_targets,), default=None
    Squared L2 norms of the lines of `y`. Required if `tol` is not None.

copy_Gram : bool, default=True
    Whether the gram matrix must be copied by the algorithm. A `False`
    value is only helpful if it is already Fortran-ordered, otherwise a
    copy is made anyway.

copy_Xy : bool, default=True
    Whether the covariance vector `Xy` must be copied by the algorithm.
    If `False`, it may be overwritten.

return_path : bool, default=False
    Whether to return every value of the nonzero coefficients along the
    forward path. Useful for cross-validation.

return_n_iter : bool, default=False
    Whether or not to return the number of iterations.

Returns
-------
coef : ndarray of shape (n_features,) or (n_features, n_targets)
    Coefficients of the OMP solution. If `return_path=True`, this contains
    the whole coefficient path. In this case its shape is
    `(n_features, n_features)` or `(n_features, n_targets, n_features)` and
    iterating over the last axis yields coefficients in increasing order
    of active features.

n_iters : list or int
    Number of active features across every target. Returned only if
    `return_n_iter` is set to True.

See Also
--------
OrthogonalMatchingPursuit : Orthogonal Matching Pursuit model (OMP).
orthogonal_mp : Solves n_targets Orthogonal Matching Pursuit problems.
lars_path : Compute Least Angle Regression or Lasso path using
    LARS algorithm.
sklearn.decomposition.sparse_encode : Generic sparse coding.
    Each column of the result is the solution to a Lasso problem.

Notes
-----
Orthogonal matching pursuit was introduced in G. Mallat, Z. Zhang,
Matching pursuits with time-frequency dictionaries, IEEE Transactions on
Signal Processing, Vol. 41, No. 12. (December 1993), pp. 3397-3415.
(https://www.di.ens.fr/~mallat/papiers/MallatPursuit93.pdf)

This implementation is based on Rubinstein, R., Zibulevsky, M. and Elad,
M., Efficient Implementation of the K-SVD Algorithm using Batch Orthogonal
Matching Pursuit Technical Report - CS Technion, April 2008.
https://www.cs.technion.ac.il/~ronrubin/Publications/KSVD-OMP-v2.pdf

Examples
--------
>>> from sklearn.datasets import make_regression
>>> from sklearn.linear_model import orthogonal_mp_gram
>>> X, y = make_regression(noise=4, random_state=0)
>>> coef = orthogonal_mp_gram(X.T @ X, X.T @ y)
>>> coef.shape
(100,)
>>> X[:1,] @ coef
array([-78.68])
r   rs   r   TNrv   zSGram OMP needs the precomputed norms in order to evaluate the error sum of squares.r   zEpsilon cannot be negativez$The number of atoms must be positiverw   r%   F)rc   rd   rI   )r   r1   asarrayr{   r:   newaxisr\   r]   r0   r~   r^   r   r   r&   r   rh   r   r7   r   r   )r`   ra   rF   rG   rz   rc   rd   rI   ro   r   r   r   r   rV   r   rR   r   rN   r   s                      rW   r   r     sy   b t3Y7D	BB	ww{rxx{Q		ww!|2::?*OMbhh((WWY3;cCIo.
=04
 	
 37566
{!+?@@
{T2L
 	
 xxTBHHQKT;4::NxxTBHHQK0

CG288A;q!tH #MT#	
 $'!AE61jCj()D(1!9:>X\9J8a<(!X56  2 !NAsFDaLv'  * 
xx{a!*zz$((zz$rY   c                       \ rS rSr% Sr\" \SSSS9S/\" \SSSS9S/S/\" S	15      S/S
.r	\
\S'   SSSS	S
.S jr\" SS9S 5       rSrg)OrthogonalMatchingPursuiti  a  Orthogonal Matching Pursuit model (OMP).

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

Parameters
----------
n_nonzero_coefs : int, default=None
    Desired number of non-zero entries in the solution. Ignored if `tol` is set.
    When `None` and `tol` is also `None`, this value is either set to 10% of
    `n_features` or 1, whichever is greater.

tol : float, default=None
    Maximum squared norm of the residual. If not None, overrides n_nonzero_coefs.

fit_intercept : bool, default=True
    Whether to calculate the intercept for this model. If set
    to false, no intercept will be used in calculations
    (i.e. data is expected to be centered).

precompute : 'auto' or bool, default='auto'
    Whether to use a precomputed Gram and Xy matrix to speed up
    calculations. Improves performance when :term:`n_targets` or
    :term:`n_samples` is very large. Note that if you already have such
    matrices, you can pass them directly to the fit method.

Attributes
----------
coef_ : ndarray of shape (n_features,) or (n_targets, n_features)
    Parameter vector (w in the formula).

intercept_ : float or ndarray of shape (n_targets,)
    Independent term in decision function.

n_iter_ : int or array-like
    Number of active features across every target.

n_nonzero_coefs_ : int or None
    The number of non-zero coefficients in the solution or `None` when `tol` is
    set. If `n_nonzero_coefs` is None and `tol` is None this value is either set
    to 10% of `n_features` or 1, whichever is greater.

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
--------
orthogonal_mp : Solves n_targets Orthogonal Matching Pursuit problems.
orthogonal_mp_gram :  Solves n_targets Orthogonal Matching Pursuit
    problems using only the Gram matrix X.T * X and the product X.T * y.
lars_path : Compute Least Angle Regression or Lasso path using LARS algorithm.
Lars : Least Angle Regression model a.k.a. LAR.
LassoLars : Lasso model fit with Least Angle Regression a.k.a. Lars.
sklearn.decomposition.sparse_encode : Generic sparse coding.
    Each column of the result is the solution to a Lasso problem.
OrthogonalMatchingPursuitCV : Cross-validated
    Orthogonal Matching Pursuit model (OMP).

Notes
-----
Orthogonal matching pursuit was introduced in G. Mallat, Z. Zhang,
Matching pursuits with time-frequency dictionaries, IEEE Transactions on
Signal Processing, Vol. 41, No. 12. (December 1993), pp. 3397-3415.
(https://www.di.ens.fr/~mallat/papiers/MallatPursuit93.pdf)

This implementation is based on Rubinstein, R., Zibulevsky, M. and Elad,
M., Efficient Implementation of the K-SVD Algorithm using Batch Orthogonal
Matching Pursuit Technical Report - CS Technion, April 2008.
https://www.cs.technion.ac.il/~ronrubin/Publications/KSVD-OMP-v2.pdf

Examples
--------
>>> from sklearn.linear_model import OrthogonalMatchingPursuit
>>> from sklearn.datasets import make_regression
>>> X, y = make_regression(noise=4, random_state=0)
>>> reg = OrthogonalMatchingPursuit().fit(X, y)
>>> reg.score(X, y)
0.9991
>>> reg.predict(X[:1,])
array([-78.3854])
r   Nri   rj   r   rl   rm   rF   rG   fit_interceptrn   _parameter_constraintsTc                4    Xl         X l        X0l        X@l        g Nr   )selfrF   rG   r   rn   s        rW   __init__"OrthogonalMatchingPursuit.__init__  s      /*$rY   rp   c                    [        XUSSS9u  pUR                  S   n[        XSU R                  U R                  SS9u  ppEpgnUR
                  S:X  a  USS2[        R                  4   nU R                  c+  U R                  c  [        [        SU-  5      S5      U l        O&U R                  b  SU l        OU R                  U l        USL a+  [        UUU R                  U R                  SSSS9u  ol        ORU R                  b  [        R                  " US	-  S
S9OSn
[!        UUU R                  U R                  U
SSSS9u  ol        U	R"                  U l        U R'                  XEU5        U $ )a@  Fit the model using X, y as training data.

Parameters
----------
X : array-like of shape (n_samples, n_features)
    Training data.

y : array-like of shape (n_samples,) or (n_samples, n_targets)
    Target values. Will be cast to X's dtype if necessary.

Returns
-------
self : object
    Returns an instance of self.
T)multi_output	y_numericr   Nr0   rv   F)rF   rG   rn   rH   ro   r   r   rx   )ra   rF   rG   rz   rc   rd   ro   )r   r:   r   rn   r   r{   r1   r   rF   rG   r}   r~   n_nonzero_coefs_r   n_iter_r   r   r7   coef__set_intercept)r   rD   rE   
n_featuresX_offsety_offsetX_scaler`   ra   r   norms_sqs              rW   fitOrthogonalMatchingPursuit.fit  sc   " TaddKWWQZ
6>$););$7
3h' 66Q;!RZZ- A'DHH,< %(C*,<(=q$AD!XX!$(D!$($8$8D!5="/ $ 5 5HH "#E< 04xx/Crvvad+H"4 $ 5 5HH&"	#E< WW
H8rY   )r   r   r   rF   r   rn   rG   )__name__
__module____qualname____firstlineno____doc__r   r   r   r   r   dict__annotations__r   r   r   __static_attributes__ rY   rW   r   r     s    Wt %Xq$vFMq$v6=#!6(+Y7	$D  % 5< 6<rY   r   c           
         U(       a@  U R                  5       n UR                  5       nUR                  5       nUR                  5       nU(       aB  U R                  SS9nX-  n X'-  nUR                  SS9n[        USS9nX-  n[        USS9nX8-  n[        U UUSSSSS9n	U	R                  S:X  a  U	SS2[
        R                  4   n	[
        R                  " U	R                  UR                  5      U-
  $ )	a  Compute the residues on left-out data for a full LARS path.

Parameters
----------
X_train : ndarray of shape (n_samples, n_features)
    The data to fit the LARS on.

y_train : ndarray of shape (n_samples)
    The target variable to fit LARS on.

X_test : ndarray of shape (n_samples, n_features)
    The data to compute the residues on.

y_test : ndarray of shape (n_samples)
    The target variable to compute the residues on.

copy : bool, default=True
    Whether X_train, X_test, y_train and y_test should be copied.  If
    False, they may be overwritten.

fit_intercept : bool, default=True
    Whether to calculate the intercept for this model. If set
    to false, no intercept will be used in calculations
    (i.e. data is expected to be centered).

max_iter : int, default=100
    Maximum numbers of iterations to perform, therefore maximum features
    to include. 100 by default.

Returns
-------
residues : ndarray of shape (n_samples, max_features)
    Residues of the prediction on the test data.
r   rx   Fr   NT)rF   rG   rn   rH   rI   r   )	r0   meanr   r   r{   r1   r   r6   r7   )
X_trainy_trainX_testy_testr0   r   max_iterX_meany_meanrR   s
             rW   _omp_path_residuesr   3  s    X ,,.,,.1%1% u5U3 E zzQam$66%''688$v--rY   c            	           \ rS rSr% SrS/S/\" \SSSS9S/S/\S/S	/S
.r\\	S'   SSSSSSS
.S jr
\" SS9S 5       rS rSrg)OrthogonalMatchingPursuitCVi~  a)  Cross-validated Orthogonal Matching Pursuit model (OMP).

See glossary entry for :term:`cross-validation estimator`.

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

Parameters
----------
copy : bool, default=True
    Whether the design matrix X must be copied by the algorithm. A false
    value is only helpful if X is already Fortran-ordered, otherwise a
    copy is made anyway.

fit_intercept : bool, default=True
    Whether to calculate the intercept for this model. If set
    to false, no intercept will be used in calculations
    (i.e. data is expected to be centered).

max_iter : int, default=None
    Maximum numbers of iterations to perform, therefore maximum features
    to include. 10% of ``n_features`` but at least 5 if available.

cv : int, cross-validation generator or iterable, default=None
    Determines the cross-validation splitting strategy.
    Possible inputs for cv are:

    - None, to use the default 5-fold cross-validation,
    - integer, to specify the number of folds.
    - :term:`CV splitter`,
    - An iterable yielding (train, test) splits as arrays of indices.

    For integer/None inputs, :class:`~sklearn.model_selection.KFold` is used.

    Refer :ref:`User Guide <cross_validation>` for the various
    cross-validation strategies that can be used here.

    .. versionchanged:: 0.22
        ``cv`` default value if None changed from 3-fold to 5-fold.

n_jobs : int, default=None
    Number of CPUs to use during the cross validation.
    ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
    ``-1`` means using all processors. See :term:`Glossary <n_jobs>`
    for more details.

verbose : bool or int, default=False
    Sets the verbosity amount.

Attributes
----------
intercept_ : float or ndarray of shape (n_targets,)
    Independent term in decision function.

coef_ : ndarray of shape (n_features,) or (n_targets, n_features)
    Parameter vector (w in the problem formulation).

n_nonzero_coefs_ : int
    Estimated number of non-zero coefficients giving the best mean squared
    error over the cross-validation folds.

n_iter_ : int or array-like
    Number of active features across every target for the model refit with
    the best hyperparameters got by cross-validating across all folds.

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
--------
orthogonal_mp : Solves n_targets Orthogonal Matching Pursuit problems.
orthogonal_mp_gram : Solves n_targets Orthogonal Matching Pursuit
    problems using only the Gram matrix X.T * X and the product X.T * y.
lars_path : Compute Least Angle Regression or Lasso path using LARS algorithm.
Lars : Least Angle Regression model a.k.a. LAR.
LassoLars : Lasso model fit with Least Angle Regression a.k.a. Lars.
OrthogonalMatchingPursuit : Orthogonal Matching Pursuit model (OMP).
LarsCV : Cross-validated Least Angle Regression model.
LassoLarsCV : Cross-validated Lasso model fit with Least Angle Regression.
sklearn.decomposition.sparse_encode : Generic sparse coding.
    Each column of the result is the solution to a Lasso problem.

Notes
-----
In `fit`, once the optimal number of non-zero coefficients is found through
cross-validation, the model is fit again using the entire training set.

Examples
--------
>>> from sklearn.linear_model import OrthogonalMatchingPursuitCV
>>> from sklearn.datasets import make_regression
>>> X, y = make_regression(n_features=100, n_informative=10,
...                        noise=4, random_state=0)
>>> reg = OrthogonalMatchingPursuitCV(cv=5).fit(X, y)
>>> reg.score(X, y)
0.9991
>>> reg.n_nonzero_coefs_
np.int64(10)
>>> reg.predict(X[:1,])
array([-78.3854])
rl   r   Nri   rj   	cv_objectverboser0   r   r   cvn_jobsr   r   TFc                L    Xl         X l        X0l        X@l        XPl        X`l        g r   r   )r   r0   r   r   r   r   r   s          rW   r   $OrthogonalMatchingPursuitCV.__init__  s#     	* rY   rp   c           	        ^ ^^^ [        UT S5        [        T TTSSS9u  mm[        TSSS9m[        T R                  SS9n[        5       (       a  [        T S40 UD6nO[        5       n[        0 S9Ul        T R                  (       d<  [        [        [        S	TR                  S
   -  5      S5      TR                  S
   5      OT R                  m[        T R                  T R                   S9" UUU U4S jUR"                  " T40 UR                  R"                  D6 5       5      n[        S U 5       5      n[$        R&                  " U Vs/ s H  oSU S-  R)                  S
S9PM     sn5      n	[$        R*                  " U	R)                  SS95      S
-   n
U
T l        [/        U
T R0                  S9R3                  TT5      nUR4                  T l        UR6                  T l        UR8                  T l        T $ s  snf )a  Fit the model using X, y as training data.

Parameters
----------
X : array-like of shape (n_samples, n_features)
    Training data.

y : array-like of shape (n_samples,)
    Target values. Will be cast to X's dtype if necessary.

**fit_params : dict
    Parameters to pass to the underlying splitter.

    .. versionadded:: 1.4
        Only available if `enable_metadata_routing=True`,
        which can be set by using
        ``sklearn.set_config(enable_metadata_routing=True)``.
        See :ref:`Metadata Routing User Guide <metadata_routing>` for
        more details.

Returns
-------
self : object
    Returns an instance of self.
r   Tr   )r   ensure_min_featuresF)r0   ensure_all_finite)
classifier)splitrv   r      )r   r   c           
   3      >#    U  HB  u  p[        [        5      " TU   TU   TU   TU   TR                  TR                  T5      v   MD     g 7fr   )r   r   r0   r   ).0traintestrD   r   r   rE   s      rW   	<genexpr>2OrthogonalMatchingPursuitCV.fit.<locals>.<genexpr>1  s`      F
  K &'%%$$		""   Ks   A
Ac              3   >   #    U  H  oR                   S    v   M     g7f)r   N)r:   )r   folds     rW   r   r   >  s     @xtZZ]xs   Nrx   r   )rF   r   )r   r   r   r   r   r   r   r   splitterr   minr}   r~   r:   r   r   r   r   r1   arrayr   argminr   r   r   r   r   
intercept_r   )r   rD   rE   
fit_paramsr   routed_paramscv_pathsmin_early_stopr   	mse_foldsbest_n_nonzero_coefsompr   s   ```         @rW   r   OrthogonalMatchingPursuitCV.fit  s   6 	*dE2T1a4QO115EBdgg%0+D%F:FM "GM%*_M" == Caggaj()1-qwwqz: 	
 4;;E F
  "xxJ]-C-C-I-IJF
 
 @x@@HHCKL84?N#q(..A.68L
	  "yyQ)?@1D 4'0,,
 #a) 	
 YY
..{{ Ms   G6c                     [        U R                  R                  S9R                  U R                  [        5       R                  SSS9S9nU$ )a"  Get metadata routing of this object.

Please check :ref:`User Guide <metadata_routing>` on how the routing
mechanism works.

.. versionadded:: 1.4

Returns
-------
routing : MetadataRouter
    A :class:`~sklearn.utils.metadata_routing.MetadataRouter` encapsulating
    routing information.
)ownerr   r   )callercallee)r   method_mapping)r   	__class__r   addr   r   )r   routers     rW   get_metadata_routing0OrthogonalMatchingPursuitCV.get_metadata_routingN  sL      dnn&=&=>BBWW(?..eG.L C 
 rY   )
r   r0   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rY   rW   r   r   ~  s    k\ #h4?FmT";$D  " 5E 6ENrY   r   )NTF)NNTTF)TTd   )2r   r>   mathr   numbersr   r   numpyr1   scipyr   scipy.linalg.lapackr   baser	   r
   r   model_selectionr   utilsr   r   r   utils._param_validationr   r   r   utils.metadata_routingr   r   r   r   r   utils.parallelr   r   utils.validationr   _baser   r   r@   rX   rh   ndarrayr   r   r   r   r   r   rY   rW   <module>r      s   ,
   "   0 A A & 6 6 K K  / , ( 
q3p G3T ^jj\$Xq$vFMq$v6= *fX"67+!{#	 #'" a a H n$Xq$yI4Pq$v6=&-[;!{#
 #'$ a a Hk 0.+ kf 
H.Vc.+ crY   