
    -iD                       S r SSK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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  SSKJr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$J%r%J&r&  SSK'J(r(J)r)  SSK*J+r+  SSK,J-r-J.r.J/r/  SS0r0\&" \	Rb                  S/\	Rb                  S/\	Rb                  S/\%" S15      S\	Rb                  S/\$" \SSSS9/\$" \SSSS9/\%" SS15      /S/\$" \SSSS9S/S/S/S/S/S/S.SS9 S2SSSSS\	Rd                  " \35      Rh                  SSSSSS .S! jj5       r5\&" \	Rb                  /\	Rb                  /\$" \SSSS9/\$" \SSSS9/\$" \SSSS9/\%" SS15      /S/\$" \SSSS9S/S/S/S/S/S/S".SS9SSSS\	Rd                  " \35      Rh                  SSSSSS#.
S$ j5       r6SSSSSSS\	Rd                  " \35      Rh                  SSSSS4S% jr7 " S& S'\\\-5      r8 " S( S)\85      r9S3S* jr:SSSSSS\	Rd                  " \35      Rh                  S4S+ jr; " S, S-\85      r< " S. S/\<5      r= " S0 S1\95      r>g)4zt
Least Angle Regression algorithm. See the documentation on the
Generalized Linear Model for a complete discussion.
    N)log)IntegralReal)interpolatelinalg)get_lapack_funcs   )MultiOutputMixinRegressorMixin_fit_context)ConvergenceWarning)check_cv)Bunch
arrayfuncsas_float_arraycheck_random_state)MetadataRouterMethodMapping_raise_for_params_routing_enabledprocess_routing)HiddenInterval
StrOptionsvalidate_params)Paralleldelayed)validate_data   )LinearModelLinearRegression_preprocess_datacheck_finiteFautobooleanleftclosedlarlassoneitherverboseXyXyGrammax_iter	alpha_minmethodcopy_Xeps	copy_Gramr,   return_pathreturn_n_iterpositiveTprefer_skip_nested_validation  )r1   r2   r3   r4   r5   r6   r7   r,   r8   r9   r:   c                R    U c  Ub  [        S5      e[        U UUUSUUUUUU	U
UUUS9$ )a  Compute Least Angle Regression or Lasso path using the LARS algorithm.

The optimization objective for the case method='lasso' is::

(1 / (2 * n_samples)) * ||y - Xw||^2_2 + alpha * ||w||_1

in the case of method='lar', the objective function is only known in
the form of an implicit equation (see discussion in [1]_).

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

Parameters
----------
X : None or ndarray of shape (n_samples, n_features)
    Input data. If X is `None`, Gram must also be `None`.
    If only the Gram matrix is available, use `lars_path_gram` instead.

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

Xy : array-like of shape (n_features,), default=None
    `Xy = X.T @ y` that can be precomputed. It is useful
    only when the Gram matrix is precomputed.

Gram : None, 'auto', bool, ndarray of shape (n_features, n_features),             default=None
    Precomputed Gram matrix `X.T @ X`, if `'auto'`, the Gram
    matrix is precomputed from the given X, if there are more samples
    than features.

max_iter : int, default=500
    Maximum number of iterations to perform, set to infinity for no limit.

alpha_min : float, default=0
    Minimum correlation along the path. It corresponds to the
    regularization parameter `alpha` in the Lasso.

method : {'lar', 'lasso'}, default='lar'
    Specifies the returned model. Select `'lar'` for Least Angle
    Regression, `'lasso'` for the Lasso.

copy_X : bool, default=True
    If `False`, `X` is overwritten.

eps : float, default=np.finfo(float).eps
    The machine-precision regularization in the computation of the
    Cholesky diagonal factors. Increase this for very ill-conditioned
    systems. Unlike the `tol` parameter in some iterative
    optimization-based algorithms, this parameter does not control
    the tolerance of the optimization.

copy_Gram : bool, default=True
    If `False`, `Gram` is overwritten.

verbose : int, default=0
    Controls output verbosity.

return_path : bool, default=True
    If `True`, returns the entire path, else returns only the
    last point of the path.

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

positive : bool, default=False
    Restrict coefficients to be >= 0.
    This option is only allowed with method 'lasso'. Note that the model
    coefficients will not converge to the ordinary-least-squares solution
    for small values of alpha. Only coefficients up to the smallest alpha
    value (`alphas_[alphas_ > 0.].min()` when fit_path=True) reached by
    the stepwise Lars-Lasso algorithm are typically in congruence with the
    solution of the coordinate descent `lasso_path` function.

Returns
-------
alphas : ndarray of shape (n_alphas + 1,)
    Maximum of covariances (in absolute value) at each iteration.
    `n_alphas` is either `max_iter`, `n_features`, or the
    number of nodes in the path with `alpha >= alpha_min`, whichever
    is smaller.

active : ndarray of shape (n_alphas,)
    Indices of active variables at the end of the path.

coefs : ndarray of shape (n_features, n_alphas + 1)
    Coefficients along the path.

n_iter : int
    Number of iterations run. Returned only if `return_n_iter` is set
    to True.

See Also
--------
lars_path_gram : Compute LARS path in the sufficient stats mode.
lasso_path : Compute Lasso path with coordinate descent.
LassoLars : Lasso model fit with Least Angle Regression a.k.a. Lars.
Lars : Least Angle Regression model a.k.a. LAR.
LassoLarsCV : Cross-validated Lasso, using the LARS algorithm.
LarsCV : Cross-validated Least Angle Regression model.
sklearn.decomposition.sparse_encode : Sparse coding.

References
----------
.. [1] "Least Angle Regression", Efron et al.
       http://statweb.stanford.edu/~tibs/ftp/lars.pdf

.. [2] `Wikipedia entry on the Least-angle regression
       <https://en.wikipedia.org/wiki/Least-angle_regression>`_

.. [3] `Wikipedia entry on the Lasso
       <https://en.wikipedia.org/wiki/Lasso_(statistics)>`_

Examples
--------
>>> from sklearn.linear_model import lars_path
>>> from sklearn.datasets import make_regression
>>> X, y, true_coef = make_regression(
...    n_samples=100, n_features=5, n_informative=2, coef=True, random_state=0
... )
>>> true_coef
array([ 0.        ,  0.        ,  0.        , 97.9, 45.7])
>>> alphas, _, estimated_coef = lars_path(X, y)
>>> alphas.shape
(3,)
>>> estimated_coef
array([[ 0.     ,  0.     ,  0.     ],
       [ 0.     ,  0.     ,  0.     ],
       [ 0.     ,  0.     ,  0.     ],
       [ 0.     , 46.96, 97.99],
       [ 0.     ,  0.     , 45.70]])
NzPX cannot be None if Gram is not NoneUse lars_path_gram to avoid passing X and y.r.   r/   r0   r1   	n_samplesr2   r3   r4   r5   r6   r7   r,   r8   r9   r:   )
ValueError_lars_path_solverr-   s                 T/var/www/html/venv/lib/python3.13/site-packages/sklearn/linear_model/_least_angle.py	lars_pathrD   ,   s]    N 	yT%;
 	
 

#     r0   r1   r@   r2   r3   r4   r5   r6   r7   r,   r8   r9   r:   )
r2   r3   r4   r5   r6   r7   r,   r8   r9   r:   c                0    [        SSU UUUUUUUUU	U
UUS9$ )a  The lars_path in the sufficient stats mode.

The optimization objective for the case method='lasso' is::

(1 / (2 * n_samples)) * ||y - Xw||^2_2 + alpha * ||w||_1

in the case of method='lar', the objective function is only known in
the form of an implicit equation (see discussion in [1]_).

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

Parameters
----------
Xy : ndarray of shape (n_features,)
    `Xy = X.T @ y`.

Gram : ndarray of shape (n_features, n_features)
    `Gram = X.T @ X`.

n_samples : int
    Equivalent size of sample.

max_iter : int, default=500
    Maximum number of iterations to perform, set to infinity for no limit.

alpha_min : float, default=0
    Minimum correlation along the path. It corresponds to the
    regularization parameter alpha parameter in the Lasso.

method : {'lar', 'lasso'}, default='lar'
    Specifies the returned model. Select `'lar'` for Least Angle
    Regression, ``'lasso'`` for the Lasso.

copy_X : bool, default=True
    If `False`, `X` is overwritten.

eps : float, default=np.finfo(float).eps
    The machine-precision regularization in the computation of the
    Cholesky diagonal factors. Increase this for very ill-conditioned
    systems. Unlike the `tol` parameter in some iterative
    optimization-based algorithms, this parameter does not control
    the tolerance of the optimization.

copy_Gram : bool, default=True
    If `False`, `Gram` is overwritten.

verbose : int, default=0
    Controls output verbosity.

return_path : bool, default=True
    If `return_path==True` returns the entire path, else returns only the
    last point of the path.

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

positive : bool, default=False
    Restrict coefficients to be >= 0.
    This option is only allowed with method 'lasso'. Note that the model
    coefficients will not converge to the ordinary-least-squares solution
    for small values of alpha. Only coefficients up to the smallest alpha
    value (`alphas_[alphas_ > 0.].min()` when `fit_path=True`) reached by
    the stepwise Lars-Lasso algorithm are typically in congruence with the
    solution of the coordinate descent lasso_path function.

Returns
-------
alphas : ndarray of shape (n_alphas + 1,)
    Maximum of covariances (in absolute value) at each iteration.
    `n_alphas` is either `max_iter`, `n_features` or the
    number of nodes in the path with `alpha >= alpha_min`, whichever
    is smaller.

active : ndarray of shape (n_alphas,)
    Indices of active variables at the end of the path.

coefs : ndarray of shape (n_features, n_alphas + 1)
    Coefficients along the path.

n_iter : int
    Number of iterations run. Returned only if `return_n_iter` is set
    to True.

See Also
--------
lars_path_gram : Compute LARS path.
lasso_path : Compute Lasso path with coordinate descent.
LassoLars : Lasso model fit with Least Angle Regression a.k.a. Lars.
Lars : Least Angle Regression model a.k.a. LAR.
LassoLarsCV : Cross-validated Lasso, using the LARS algorithm.
LarsCV : Cross-validated Least Angle Regression model.
sklearn.decomposition.sparse_encode : Sparse coding.

References
----------
.. [1] "Least Angle Regression", Efron et al.
       http://statweb.stanford.edu/~tibs/ftp/lars.pdf

.. [2] `Wikipedia entry on the Least-angle regression
       <https://en.wikipedia.org/wiki/Least-angle_regression>`_

.. [3] `Wikipedia entry on the Lasso
       <https://en.wikipedia.org/wiki/Lasso_(statistics)>`_

Examples
--------
>>> from sklearn.linear_model import lars_path_gram
>>> from sklearn.datasets import make_regression
>>> X, y, true_coef = make_regression(
...    n_samples=100, n_features=5, n_informative=2, coef=True, random_state=0
... )
>>> true_coef
array([ 0.        ,  0.        ,  0.        , 97.9, 45.7])
>>> alphas, _, estimated_coef = lars_path_gram(X.T @ y, X.T @ X, n_samples=100)
>>> alphas.shape
(3,)
>>> estimated_coef
array([[ 0.     ,  0.     ,  0.     ],
       [ 0.     ,  0.     ,  0.     ],
       [ 0.     ,  0.     ,  0.     ],
       [ 0.     , 46.96, 97.99],
       [ 0.     ,  0.     , 45.70]])
Nr?   )rB   rF   s                rC   lars_path_gramrH      s?    z 

# rE   c                    US:X  a  U(       a  [        S5      eUb  UOUR                  nUc"  [        R                  " U R                  U5      nOUR                  5       nUb  USL a  SnU c  [        S5      eO[        U[        5      (       a  US:X  d  USL aJ  USL d   U R                  S   U R                  S	   :  a"  [        R                  " U R                  U 5      nOSnOU
(       a  UR                  5       nUc  U R                  S	   nO,UR                  S   nUR                  UU4:w  a  [        S
5      eU(       a  U b  Uc  U R                  S5      n [        UU5      n[        S XX#4 5       5      n[        U5      S	:X  a  [        [        U5      5      nO[        R                  nU(       a3  [        R                  " US	-   U4US9n[        R                  " US	-   US9nOV[        R                  " UUS9[        R                  " UUS9nn[        R                   " S/US9[        R                   " S/US9nnSu  nn[#        5       [        R$                  " U5      nn[        R&                  " U[        R(                  S9nSnUc=  [        R&                  " UU4U R*                  S9n [,        R.                  " SU 45      u  n!n"O<[        R&                  " UU4UR*                  S9n [,        R.                  " SU45      u  n!n"[1        SU 45      u  n#U(       aO  US	:  a  [3        S5        O=[4        R6                  R9                  S5        [4        R6                  R;                  5         [        R<                  " [        R>                  5      R@                  n$[        R<                  " UR*                  5      RB                  n%[        R<                  " [        R>                  5      RD                  n&Ub   UR                  5       n'UR                  5       n( UR                  (       an  U(       a  [        RF                  " U5      n)O*[        RF                  " [        RH                  " U5      5      n)UU)   n*U(       a  U*n+O[        RJ                  " U*5      n+OSn+U(       a:  WU[        RL                  4   nWU   nUUS	-
  [        RL                  4   nUUS	-
     nU+U-  WS'   US   UU&-   ::  aP  [I        US   U-
  5      U&:  a-  US:  a"  WS   U-
  US   US   -
  -  n,WU,WU-
  -  -   USS& UUS'   U(       a  WWU'   GOUU:  d  UU:  a  GOU(       Gd  U(       a  [        RN                  " W*5      UU'   O[        RP                  " W*5      UU'   UW)U-   n.n-U!" UU)   US   5      u  UU)'   US'   UU-   UU.   sUU.'   UU-'   Un/US	S nUc  U!" U R                  U.   U R                  U-   5      u  U R                  U.'   U R                  U-'   U"" U R                  U   5      S-  n0[        R                  " U R                  U   U R                  SU R                  5      U USU24'   OWU!" UU-   UU.   5      u  UU-'   UU.'   U!" USS2U-4   USS2U.4   5      u  USS2U-4'   USS2U.4'   UUU4   n0UUSU24   U USU24'   U(       a0  [,        RR                  " U SU2SU24   U USU24   4SS	SS.[T        D6  [        R                  " U USU24   U USU24   5      n1[W        [        RX                  " [        RH                  " U0U1-
  5      5      U	5      n2U2U UU4'   U2S:  aR  [Z        R\                  " SUUR_                  5       UU24-  [`        5        U/nSUS'   U!" UU)   US   5      u  UU)'   US'   GM  URc                  UU   5        US	-  nUS	:  a!  [3        U< SUS   < SS< SU< SU+< 3	5        US:X  aR  US:  aL  WS   US   :  a@  [Z        R\                  " SUUR_                  5       UR_                  5       U4-  [`        5        GOU#" U SU2SU24   USU SS9u  n3n4U3R                  S	:X  a  U3S:X  a	  S	U3S'   Sn5GOS[        RX                  " [        Rd                  " U3USU -  5      5      -  n5[        Rf                  " U55      (       d  Sn6U SU2SU24   R                  5       n7[        Rf                  " U55      (       d  U7Rh                  SSUS	-   2==   SU6-  U	-  -  ss'   U#" U7USU SS9u  n3n4[W        [        Rd                  " U3USU -  5      U	5      n8S[        RX                  " U85      -  n5U6S	-  n6[        Rf                  " U55      (       d  M  U3U5-  n3UcS  [        R                  " U R                  SU R                  U35      n9[        R                  " U R                  US U95      n:O*[        R                  " USU2US24   R                  U35      n:[        Rj                  " U:U%U:S 9  [l        Rn                  " U+U-
  U5U:-
  U$-   -  5      n;U(       a  [        U;U+U5-  5      n<O2[l        Rn                  " U+U-   U5U:-   U$-   -  5      n=[        U;U=U+U5-  5      n<SnWU   * U3U$-   -  n>[l        Rn                  " U>5      n?U?U<:  a5  [        Rp                  " U>U?:H  5      S   SSS2   n@UU@   * UU@'   US:X  a  U?n<SnUS	-  nU(       ay  UWR                  S   :  aX  AAAAS[W        S	UU-
  5      -  nA[        Rr                  " UUUA-   U45      nSUUA* S& [        Rr                  " WUUA-   5      nSUUA* S& UU   nUUS	-
     nO UnUS   WS'   [        Rt                  " U5      nUU   U<U3-  -   UU'   UU<U:-  -  nU(       GaA  US:X  Ga:  W@ H#  nB[l        Rv                  " U SU2SU24   UB5        M%     US	-  nW@ VBs/ s H  nBURy                  UB5      PM     nCnBUc  W@ Hs  nB[{        UBU5       H`  n6U!" U R                  U6   U R                  U6S	-      5      u  U R                  U6'   U R                  U6S	-   '   UU6S	-      UU6   sUU6'   UU6S	-   '   Mb     Mu     U[        R                  " U SS2SU24   UU   5      -
  nD[        R                  " U R                  U   UD5      nE[        R|                  UEU4   nOW@ Hy  nB[{        UBU5       Hf  n6UU6S	-      UU6   sUU6'   UU6S	-   '   U!" UU6   UU6S	-      5      u  UU6'   UU6S	-   '   U!" USS2U64   USS2U6S	-   4   5      u  USS2U64'   USS2U6S	-   4'   Mh     M{     W(WC   [        R                  " W'UC   U5      -
  nE[        R|                  UEU4   n[        R~                  " UW@5      n[        Rb                  " US5      nUS	:  a'  [3        U< SS< SWC< SU< S[I        WE5      < 3	5        G	M  U(       a6  WSUS	-    nWSUS	-    nU(       a  UUUR                  U4$ UUUR                  4$ U(       a  UUWU4$ UUW4$ s  snBf )!a  Compute Least Angle Regression or Lasso path using LARS algorithm [1]

The optimization objective for the case method='lasso' is::

(1 / (2 * n_samples)) * ||y - Xw||^2_2 + alpha * ||w||_1

in the case of method='lar', the objective function is only known in
the form of an implicit equation (see discussion in [1])

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

Parameters
----------
X : None or ndarray of shape (n_samples, n_features)
    Input data. Note that if X is None then Gram must be specified,
    i.e., cannot be None or False.

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

Xy : array-like of shape (n_features,), default=None
    `Xy = np.dot(X.T, y)` that can be precomputed. It is useful
    only when the Gram matrix is precomputed.

Gram : None, 'auto' or array-like of shape (n_features, n_features),             default=None
    Precomputed Gram matrix `(X' * X)`, if ``'auto'``, the Gram
    matrix is precomputed from the given X, if there are more samples
    than features.

n_samples : int or float, default=None
    Equivalent size of sample. If `None`, it will be `n_samples`.

max_iter : int, default=500
    Maximum number of iterations to perform, set to infinity for no limit.

alpha_min : float, default=0
    Minimum correlation along the path. It corresponds to the
    regularization parameter alpha parameter in the Lasso.

method : {'lar', 'lasso'}, default='lar'
    Specifies the returned model. Select ``'lar'`` for Least Angle
    Regression, ``'lasso'`` for the Lasso.

copy_X : bool, default=True
    If ``False``, ``X`` is overwritten.

eps : float, default=np.finfo(float).eps
    The machine-precision regularization in the computation of the
    Cholesky diagonal factors. Increase this for very ill-conditioned
    systems. Unlike the ``tol`` parameter in some iterative
    optimization-based algorithms, this parameter does not control
    the tolerance of the optimization.

copy_Gram : bool, default=True
    If ``False``, ``Gram`` is overwritten.

verbose : int, default=0
    Controls output verbosity.

return_path : bool, default=True
    If ``return_path==True`` returns the entire path, else returns only the
    last point of the path.

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

positive : bool, default=False
    Restrict coefficients to be >= 0.
    This option is only allowed with method 'lasso'. Note that the model
    coefficients will not converge to the ordinary-least-squares solution
    for small values of alpha. Only coefficients up to the smallest alpha
    value (``alphas_[alphas_ > 0.].min()`` when fit_path=True) reached by
    the stepwise Lars-Lasso algorithm are typically in congruence with the
    solution of the coordinate descent lasso_path function.

Returns
-------
alphas : array-like of shape (n_alphas + 1,)
    Maximum of covariances (in absolute value) at each iteration.
    ``n_alphas`` is either ``max_iter``, ``n_features`` or the
    number of nodes in the path with ``alpha >= alpha_min``, whichever
    is smaller.

active : array-like of shape (n_alphas,)
    Indices of active variables at the end of the path.

coefs : array-like of shape (n_features, n_alphas + 1)
    Coefficients along the path

n_iter : int
    Number of iterations run. Returned only if return_n_iter is set
    to True.

See Also
--------
lasso_path
LassoLars
Lars
LassoLarsCV
LarsCV
sklearn.decomposition.sparse_encode

References
----------
.. [1] "Least Angle Regression", Efron et al.
       http://statweb.stanford.edu/~tibs/ftp/lars.pdf

.. [2] `Wikipedia entry on the Least-angle regression
       <https://en.wikipedia.org/wiki/Least-angle_regression>`_

.. [3] `Wikipedia entry on the Lasso
       <https://en.wikipedia.org/wiki/Lasso_(statistics)>`_

r)   z:Positive constraint not supported for 'lar' coding method.NFz&X and Gram cannot both be unspecified.r$   Tr   r   z2The shapes of the inputs Gram and Xy do not match.Fc              3   B   #    U  H  oc  M  UR                   v   M     g 7fNdtype).0as     rC   	<genexpr>$_lars_path_solver.<locals>.<genexpr>D  s     D"2Q"2s   rM           )r   r   )swapnrm2)potrsz(Step		Added		Dropped		Active set size		C.r	   )transloweroverwrite_bgHz>zRegressors in active set degenerate. Dropping a regressor, after %i iterations, i.e. alpha=%.3e, with an active set of %i regressors, and the smallest cholesky pivot element being %.3e. Reduce max_iter or increase eps parameters.z		 r*   zEarly stopping the lars path, as the residues are small and the current value of alpha is no longer well controlled. %i iterations, alpha=%.3e, previous alpha=%.3e, with an active set of %i regressors.)rY   .      ?)decimalsout)@rA   sizenpdotTcopy
isinstancestrshapeminsetlennextiterfloat64zerosarraylistarangeemptyint8rN   r   get_blas_funcsr   printsysstdoutwriteflushfinfofloat32tiny	precisionr6   argmaxabsfabsnewaxis	ones_likesignsolve_triangularSOLVE_TRIANGULAR_ARGSmaxsqrtwarningswarnitemr   appendsumisfiniteflataroundr   min_poswhereresize
zeros_likecholesky_deletepopranger_delete)Fr.   r/   r0   r1   r@   r2   r3   r4   r5   r6   r7   r,   r8   r9   r:   Cov
n_featuresmax_featuresdtypesreturn_dtypecoefsalphascoef	prev_coefalpha
prev_alphan_itern_activeactiveindicessign_activedropLrT   rU   solve_choleskytiny32cov_precisionequality_tolerance	Gram_copyCov_copyC_idxC_CssmnCov_not_shortenedcvdiagleast_squares_AAiL_tmpeq_dircorr_eq_dirg1gamma_g2zz_posidxadd_featuresiidrop_idxresidualtempsF                                                                         rC   rB   rB     s   H 8UVV&2	I	zffQSS!nggi|tu}9EFF 
T3

DFNtt|4<1771:
266!##q>DD	yy{|WWQZ
YYq\
::*j11QRR!-DL FF3Kx,LD1"2DDF
6{aDL) zz,*J7|L,*,? HHZ|4HHZ|4 
 HHcU,/HHcU,/  FHfbii
3GF((<rww7KD |HHlL1A**+;aTB
dHHlL1D**+;cVD
d(aT:^Q;DEJJS!JJXXbjj!&&FHHSYY'11M"**-11IIK	88:
88		#		"&&+.UBGGBKA62::-.E=D
BJJ 67Jfqj)Iy=a8y#55558i'(+==A: %Q-)3
1a8PQB'"y0@*AADG$a $fXZ!7 (*R(8H%(*H%UX-qA!%c%j#a&!9CJA%,QZ"GAJ
 #ab'C|!%acc!facc!f!5AAX'1,)+Hqss9H~?O?O)P(IXI%& $(Qa#9 Qa)-d1a4j$q!t*)E&QT
DAJ8+,)-h		.A)B(IXI%& ''ixi(*+h		)*  $ , q9H9,-q9H91D/EFArwwrvva!e}-s3D$(Ah !d{ C uzz|Xt<= '	 (A%)#e*c!f%="E
CFMM'(+,MH{4:F2JHVWX W!
1a0H
 MM "(z7H( S	T
 #  *ixi("#[(%;4
q "}'9!"M#B rwwrvvmk)86L&LMNNB;;r??yy)8)+,113++b//GGOx!|O,A<,'5K	2$($M1 bff][(5K%KLcRCrwws|+BFA ++b// RM<VVACC	N,,m<F &&XY8K
 &&ixi&:!;!=!=}MK 			+;GSR+-=-F GHQV_F##QWk1AF1J$KLBRR(F &\M]V34""1%6>((1:&q)$B$/C !,C 00K D!Q'%Y 3q<(+B#DD		%&<*?)LM()|mn%66L+@A)*}~&=Dfqj)I I!!HJqM==&D (6M+AAV 	v## Fg%**1YhY		-A+BBG  MH1452

2H5|B"2x0-1!##a&!##a!e*-E*AAE
5<QU^WQZ2
GAEN 1  rvva9H9otF|DDvvacc(mX6eeD#I&B"2x05<QU^WQZ2
GAEN/3DGT!a%[/I,Qa!e59$q!t*d1aRSe8n5U2QT
DAEN 1   )BFF9X3F,MMeeD#I&))K5K))K5K{r8Xs4yBM V &1*%l
#6577F226577**&$..&$&&k 6s   (yc                   >   \ rS rSr% SrS/S/S\" S15      \R                  \" S5      /\	" \
SSSS	9/\	" \S
SSS	9/S/S/\	" \S
SSS	9S/S/S.	r\\S'   SrSrSSSS\R"                  " \5      R&                  SSSSS.	S jr\S 5       rSS jr\" SS9SS j5       rSrg)Larsi  aC  Least Angle Regression model a.k.a. LAR.

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

Parameters
----------
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).

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

precompute : bool, 'auto' or array-like , default='auto'
    Whether to use a precomputed Gram matrix to speed up
    calculations. If set to ``'auto'`` let us decide. The Gram
    matrix can also be passed as argument.

n_nonzero_coefs : int, default=500
    Target number of non-zero coefficients. Use ``np.inf`` for no limit.

eps : float, default=np.finfo(float).eps
    The machine-precision regularization in the computation of the
    Cholesky diagonal factors. Increase this for very ill-conditioned
    systems. Unlike the ``tol`` parameter in some iterative
    optimization-based algorithms, this parameter does not control
    the tolerance of the optimization.

copy_X : bool, default=True
    If ``True``, X will be copied; else, it may be overwritten.

fit_path : bool, default=True
    If True the full path is stored in the ``coef_path_`` attribute.
    If you compute the solution for a large problem or many targets,
    setting ``fit_path`` to ``False`` will lead to a speedup, especially
    with a small alpha.

jitter : float, default=None
    Upper bound on a uniform noise parameter to be added to the
    `y` values, to satisfy the model's assumption of
    one-at-a-time computations. Might help with stability.

    .. versionadded:: 0.23

random_state : int, RandomState instance or None, default=None
    Determines random number generation for jittering. Pass an int
    for reproducible output across multiple function calls.
    See :term:`Glossary <random_state>`. Ignored if `jitter` is None.

    .. versionadded:: 0.23

Attributes
----------
alphas_ : array-like of shape (n_alphas + 1,) or list of such arrays
    Maximum of covariances (in absolute value) at each iteration.
    ``n_alphas`` is either ``max_iter``, ``n_features`` or the
    number of nodes in the path with ``alpha >= alpha_min``, whichever
    is smaller. If this is a list of array-like, the length of the outer
    list is `n_targets`.

active_ : list of shape (n_alphas,) or list of such lists
    Indices of active variables at the end of the path.
    If this is a list of list, the length of the outer list is `n_targets`.

coef_path_ : array-like of shape (n_features, n_alphas + 1) or list             of such arrays
    The varying values of the coefficients along the path. It is not
    present if the ``fit_path`` parameter is ``False``. If this is a list
    of array-like, the length of the outer list is `n_targets`.

coef_ : array-like of shape (n_features,) or (n_targets, n_features)
    Parameter vector (w in the formulation formula).

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

n_iter_ : array-like or int
    The number of iterations taken by lars_path to find the
    grid of alphas for each target.

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
--------
lars_path: Compute Least Angle Regression or Lasso
    path using LARS algorithm.
LarsCV : Cross-validated Least Angle Regression model.
sklearn.decomposition.sparse_encode : Sparse coding.

Examples
--------
>>> from sklearn import linear_model
>>> reg = linear_model.Lars(n_nonzero_coefs=1)
>>> reg.fit([[-1, 1], [0, 0], [1, 1]], [-1.1111, 0, -1.1111])
Lars(n_nonzero_coefs=1)
>>> print(reg.coef_)
[ 0. -1.11]
r%   r,   r$   Nr   r&   r'   r   random_state	fit_interceptr,   
precomputen_nonzero_coefsr6   r5   fit_pathjitterr   _parameter_constraintsr)   FTr=   c       	         p    Xl         X l        X0l        X@l        XPl        X`l        Xpl        Xl        Xl        g rL   r   )
selfr   r,   r   r   r6   r5   r   r   r   s
             rC   __init__Lars.__init__  s4     +$. (rE   c                     [        U S5      (       de  U SL d?  U S:X  a   UR                  S   UR                  S   :  d  U S:X  a4  UR                  S   S:  a!  [        R                  " UR                  U5      n U $ )N	__array__Tr$   r   r   )hasattrrg   ra   rb   rc   )r   r.   r/   s      rC   	_get_gramLars._get_gram,  se    
K004f$aggaj)@f$aQJrE   c                    UR                   S   n[        XU R                  U R                  S9u  ppn
UR                  S:X  a  USS2[
        R                  4   nUR                   S   nU R                  U R                  X5      n/ U l	        / U l
        [
        R                  " X4UR                  S9U l        U(       Ga  / U l        / U l        [!        U5       H  nUc  SOUSS2U4   n[#        UUSS2U4   UUU R                  SUU R$                  ['        SU R(                  S-
  5      UU R*                  SSU R,                  S9u  nnnnU R                  R/                  U5        U R                  R/                  U5        U R                  R/                  U5        U R                  R/                  U5        USS2S4   U R                  U'   M     US:X  ao  U R                  U R                  U R                  U R                  4 Vs/ s H  nUS   PM
     snu  U l	        U l        U l        U l        U R                  S   U l
        O[!        U5       H  nUc  SOUSS2U4   n[#        UUSS2U4   UUU R                  SUU R$                  ['        SU R(                  S-
  5      UU R*                  S	SU R,                  S9u  nnU R                  U'   nU R                  R/                  U5        U R                  R/                  U5        M     US:X  a(  U R                  S   U l	        U R                  S   U l
        U R1                  XU
5        U $ s  snf )
z=Auxiliary method to fit the model using X, y as training datar   r   rd   NrM   Tr   )r1   r0   r5   r7   r3   r4   r,   r2   r6   r8   r9   r:   r[   F)rg   r"   r   r5   ndimra   r   r   r   alphas_n_iter_rr   rN   coef_active_
coef_path_r   rD   r4   r   r,   r6   r:   r   _set_intercept)r   r.   r/   r2   r   r   r0   r   X_offsety_offsetX_scale	n_targetsr1   kthis_Xyr   r   	coef_pathr   rP   r   s                        rC   _fit	Lars._fit7  s   WWQZ
,< 2 2-
)h' 66Q;!RZZ- AGGAJ	~~dooq4XXy5QWWE
DL DO9%"$*$"QT(5>adG;;"#;;4<<!#34% $"&!]]62	7  ##F+##F+##G,&&y1 )!R% 0

1- &0 A~ #llDLL$//4::VKV aDVKGdlDOTZ  $||A9%"$*$"QT(4=adG;;"#;;4<<!#34% %"&!]]514::a='  ##F+##G,' &( A~#||A#||AH8?Ks   Mr;   c           	      d   [        XUSSSS9u  p[        U SS5      n[        U S5      (       a  SnU R                  nOU R                  nU R
                  b<  [        U R                  5      nUR                  U R
                  [        U5      S9nX'-   nU R                  UUUUU R                  US9  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.

Xy : array-like of shape (n_features,) or (n_features, n_targets),                 default=None
    Xy = np.dot(X.T, y) that can be precomputed. It is useful
    only when the Gram matrix is precomputed.

Returns
-------
self : object
    Returns an instance of self.
T)force_writeable	y_numericmulti_outputr   rS   r   )highr`   )r2   r   r   r0   )r   getattrr   r   r2   r   r   r   uniformrj   r   r   )r   r.   r/   r0   r   r2   rngnoises           rC   fitLars.fit  s    , Q4
 gs+4*++E++H}}H;;"$T%6%67CKKT[[s1vK>E	A		]] 	 	
 rE   )r   r   r   r   r5   r6   r   r   r   r   r   r   r   r,   rL   )__name__
__module____qualname____firstlineno____doc__r   ra   ndarrayr   r   r   r   r   dict__annotations__r4   r:   rz   floatr6   r   staticmethodr   r   r   r   __static_attributes__ rE   rC   r   r     s    k\ $; *fX"6

F4LQ$Xq$vFGq$v67+KD!T&94@'(
$D 
 FH
 HHUO).  N` 5/ 6/rE   r   c                       \ rS rSr% Sr0 \R                  E\" \SSSS9/\" \	SSSS9/S/S.Er\
\S	'   \R                  S
5        Sr SSSSS\R                  " \5      R"                  SSSSSS.
S jjrSrg)	LassoLarsi  a  Lasso model fit with Least Angle Regression a.k.a. Lars.

It is a Linear Model trained with an L1 prior as regularizer.

The optimization objective for Lasso is::

(1 / (2 * n_samples)) * ||y - Xw||^2_2 + alpha * ||w||_1

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

Parameters
----------
alpha : float, default=1.0
    Constant that multiplies the penalty term. Defaults to 1.0.
    ``alpha = 0`` is equivalent to an ordinary least square, solved
    by :class:`LinearRegression`. For numerical reasons, using
    ``alpha = 0`` with the LassoLars object is not advised and you
    should prefer the LinearRegression object.

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).

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

precompute : bool, 'auto' or array-like, default='auto'
    Whether to use a precomputed Gram matrix to speed up
    calculations. If set to ``'auto'`` let us decide. The Gram
    matrix can also be passed as argument.

max_iter : int, default=500
    Maximum number of iterations to perform.

eps : float, default=np.finfo(float).eps
    The machine-precision regularization in the computation of the
    Cholesky diagonal factors. Increase this for very ill-conditioned
    systems. Unlike the ``tol`` parameter in some iterative
    optimization-based algorithms, this parameter does not control
    the tolerance of the optimization.

copy_X : bool, default=True
    If True, X will be copied; else, it may be overwritten.

fit_path : bool, default=True
    If ``True`` the full path is stored in the ``coef_path_`` attribute.
    If you compute the solution for a large problem or many targets,
    setting ``fit_path`` to ``False`` will lead to a speedup, especially
    with a small alpha.

positive : bool, default=False
    Restrict coefficients to be >= 0. Be aware that you might want to
    remove fit_intercept which is set True by default.
    Under the positive restriction the model coefficients will not converge
    to the ordinary-least-squares solution for small values of alpha.
    Only coefficients up to the smallest alpha value (``alphas_[alphas_ >
    0.].min()`` when fit_path=True) reached by the stepwise Lars-Lasso
    algorithm are typically in congruence with the solution of the
    coordinate descent Lasso estimator.

jitter : float, default=None
    Upper bound on a uniform noise parameter to be added to the
    `y` values, to satisfy the model's assumption of
    one-at-a-time computations. Might help with stability.

    .. versionadded:: 0.23

random_state : int, RandomState instance or None, default=None
    Determines random number generation for jittering. Pass an int
    for reproducible output across multiple function calls.
    See :term:`Glossary <random_state>`. Ignored if `jitter` is None.

    .. versionadded:: 0.23

Attributes
----------
alphas_ : array-like of shape (n_alphas + 1,) or list of such arrays
    Maximum of covariances (in absolute value) at each iteration.
    ``n_alphas`` is either ``max_iter``, ``n_features`` or the
    number of nodes in the path with ``alpha >= alpha_min``, whichever
    is smaller. If this is a list of array-like, the length of the outer
    list is `n_targets`.

active_ : list of length n_alphas or list of such lists
    Indices of active variables at the end of the path.
    If this is a list of list, the length of the outer list is `n_targets`.

coef_path_ : array-like of shape (n_features, n_alphas + 1) or list             of such arrays
    If a list is passed it's expected to be one of n_targets such arrays.
    The varying values of the coefficients along the path. It is not
    present if the ``fit_path`` parameter is ``False``. If this is a list
    of array-like, the length of the outer list is `n_targets`.

coef_ : array-like of shape (n_features,) or (n_targets, n_features)
    Parameter vector (w in the formulation formula).

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

n_iter_ : array-like or int
    The number of iterations taken by lars_path to find the
    grid of alphas for each target.

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
--------
lars_path : Compute Least Angle Regression or Lasso
    path using LARS algorithm.
lasso_path : Compute Lasso path with coordinate descent.
Lasso : Linear Model trained with L1 prior as
    regularizer (aka the Lasso).
LassoCV : Lasso linear model with iterative fitting
    along a regularization path.
LassoLarsCV: Cross-validated Lasso, using the LARS algorithm.
LassoLarsIC : Lasso model fit with Lars using BIC
    or AIC for model selection.
sklearn.decomposition.sparse_encode : Sparse coding.

Examples
--------
>>> from sklearn import linear_model
>>> reg = linear_model.LassoLars(alpha=0.01)
>>> reg.fit([[-1, 1], [0, 0], [1, 1]], [-1, 0, -1])
LassoLars(alpha=0.01)
>>> print(reg.coef_)
[ 0.         -0.955]
r   Nr&   r'   r%   )r   r2   r:   r   r   r*   TFr$   r=   )
r   r,   r   r2   r6   r5   r   r:   r   r   c       
             Xl         X l        XPl        X0l        Xl        X@l        Xpl        X`l        Xl        Xl	        Xl
        g rL   )r   r   r2   r,   r:   r   r5   r6   r   r   r   )r   r   r   r,   r   r2   r6   r5   r   r:   r   r   s               rC   r   LassoLars.__init__Q  s=     
*  $ (rE   )r   r5   r6   r   r   r   r2   r:   r   r   r,   )r]   )r   r   r   r  r  r   r   r   r   r   r  r  r   r4   ra   rz   r  r6   r   r  r	  rE   rC   r  r    s    JX$

%
%$4D89h4?@K	$D  01F ) HHUO) )rE   r  c                 j    U(       d  U R                   R                  (       d  U R                  5       $ U $ rL   )flags	writeablerd   )ro   rd   s     rC   _check_copy_and_writeabler  q  s"    5;;((zz|LrE   c                    [        X5      n [        X5      n[        X%5      n[        X55      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X=-  n[        U UUSSU[	        SUS-
  5      U	U
US9
u  pn[
        R                  " UU5      USS2[
        R                  4   -
  nXUUR                  4$ )a	  Compute the residues on left-out data for a full LARS path

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

y_train : array-like of shape (n_samples,)
    The target variable to fit LARS on

X_test : array-like of shape (n_samples, n_features)
    The data to compute the residues on

y_test : array-like of shape (n_samples,)
    The target variable to compute the residues on

Gram : None, 'auto' or array-like of shape (n_features, n_features),             default=None
    Precomputed Gram matrix (X' * X), if ``'auto'``, the Gram
    matrix is precomputed from the given X, if there are more samples
    than features

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

method : {'lar' , 'lasso'}, default='lar'
    Specifies the returned model. Select ``'lar'`` for Least Angle
    Regression, ``'lasso'`` for the Lasso.

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

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).

positive : bool, default=False
    Restrict coefficients to be >= 0. Be aware that you might want to
    remove fit_intercept which is set True by default.
    See reservations for using this option in combination with method
    'lasso' for expected small values of alpha in the doc of LassoLarsCV
    and LassoLarsIC.

max_iter : int, default=500
    Maximum number of iterations to perform.

eps : float, default=np.finfo(float).eps
    The machine-precision regularization in the computation of the
    Cholesky diagonal factors. Increase this for very ill-conditioned
    systems. Unlike the ``tol`` parameter in some iterative
    optimization-based algorithms, this parameter does not control
    the tolerance of the optimization.

Returns
--------
alphas : array-like of shape (n_alphas,)
    Maximum of covariances (in absolute value) at each iteration.
    ``n_alphas`` is either ``max_iter`` or ``n_features``, whichever
    is smaller.

active : list
    Indices of active variables at the end of the path.

coefs : array-like of shape (n_features, n_alphas)
    Coefficients along the path

residues : array-like of shape (n_alphas, n_samples)
    Residues of the prediction on the test data
r   axisFrd   r   )r1   r5   r7   r4   r,   r2   r6   r:   N)	r  meanr   rD   r   ra   rb   r   rc   )X_trainy_trainX_testy_testr1   rd   r4   r,   r   r2   r6   r:   X_meany_meanr   r   r   residuess                     rC   _lars_path_residuesr  w  s    j (6G'6G&v4F&v4F1%1% u5U3%Aw{#FE vvfe$vam'<<H5(**,,rE   c            
       6  ^  \ rS rSr% Sr0 \R                  E\" \SSSS9/S/\" \SSSS9/\S/S	.Er\	\
S
'   S H  r\R                  \5        M     SrSSSSSSS\R                  " \5      R"                  SS.	U 4S jjrU 4S jr\" SS9S 5       rS rSrU =r$ )LarsCVi  a  Cross-validated Least Angle Regression model.

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

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

Parameters
----------
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).

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

max_iter : int, default=500
    Maximum number of iterations to perform.

precompute : bool, 'auto' or array-like , default='auto'
    Whether to use a precomputed Gram matrix to speed up
    calculations. If set to ``'auto'`` let us decide. The Gram matrix
    cannot be passed as argument since we will use only subsets of X.

cv : int, cross-validation generator or an 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.

max_n_alphas : int, default=1000
    The maximum number of points on the path used to compute the
    residuals in the cross-validation.

n_jobs : int or None, 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.

eps : float, default=np.finfo(float).eps
    The machine-precision regularization in the computation of the
    Cholesky diagonal factors. Increase this for very ill-conditioned
    systems. Unlike the ``tol`` parameter in some iterative
    optimization-based algorithms, this parameter does not control
    the tolerance of the optimization.

copy_X : bool, default=True
    If ``True``, X will be copied; else, it may be overwritten.

Attributes
----------
active_ : list of length n_alphas or list of such lists
    Indices of active variables at the end of the path.
    If this is a list of lists, the outer list length is `n_targets`.

coef_ : array-like of shape (n_features,)
    parameter vector (w in the formulation formula)

intercept_ : float
    independent term in decision function

coef_path_ : array-like of shape (n_features, n_alphas)
    the varying values of the coefficients along the path

alpha_ : float
    the estimated regularization parameter alpha

alphas_ : array-like of shape (n_alphas,)
    the different values of alpha along the path

cv_alphas_ : array-like of shape (n_cv_alphas,)
    all the values of alpha along the path for the different folds

mse_path_ : array-like of shape (n_folds, n_cv_alphas)
    the mean square error on left-out for each fold along the path
    (alpha values given by ``cv_alphas``)

n_iter_ : array-like or int
    the number of iterations run by Lars with the optimal alpha.

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
--------
lars_path : Compute Least Angle Regression or Lasso
    path using LARS algorithm.
lasso_path : Compute Lasso path with coordinate descent.
Lasso : Linear Model trained with L1 prior as
    regularizer (aka the Lasso).
LassoCV : Lasso linear model with iterative fitting
    along a regularization path.
LassoLars : Lasso model fit with Least Angle Regression a.k.a. Lars.
LassoLarsIC : Lasso model fit with Lars using BIC
    or AIC for model selection.
sklearn.decomposition.sparse_encode : Sparse coding.

Notes
-----
In `fit`, once the best parameter `alpha` is found through
cross-validation, the model is fit again using the entire training set.

Examples
--------
>>> from sklearn.linear_model import LarsCV
>>> from sklearn.datasets import make_regression
>>> X, y = make_regression(n_samples=200, noise=4.0, random_state=0)
>>> reg = LarsCV(cv=5).fit(X, y)
>>> reg.score(X, y)
0.9996
>>> reg.alpha_
np.float64(0.2961)
>>> reg.predict(X[:1,])
array([154.3996])
r   Nr&   r'   	cv_objectr   )r2   cvmax_n_alphasn_jobsr   )r   r   r   r   r)   TFr=   r$     )	r   r,   r2   r   r"  r#  r$  r6   r5   c       	   
      \   > X0l         XPl        X`l        Xpl        [        T
U ]  UUUSUU	SS9  g )Nr=   T)r   r,   r   r   r6   r5   r   )r2   r"  r#  r$  superr   )r   r   r,   r2   r   r"  r#  r$  r6   r5   	__class__s             rC   r   LarsCV.__init__  sA     !('! 	 	
rE   c                 F   > [         TU ]  5       nSUR                  l        U$ NFr'  __sklearn_tags__target_tagsr   r   tagsr(  s     rC   r-  LarsCV.__sklearn_tags__  #    w')(-%rE   r;   c                   ^ ^^^ [        UT S5        [        T TTSSS9u  mm[        TT R                  S9m[        TT R                  S9m[	        T R
                  SS9n[        5       (       a  [        T S40 UD6nO[        [        0 S9S9nT R                  m[        TS	5      (       a/  [        R                  " S
T R                  R                  -  5        Sm[        T R                   T R"                  S9" UUU U4S jUR$                  " TT40 UR&                  R$                  D6 5       5      n[(        R*                  " [-        [/        U6 5      5      n[(        R0                  " U5      n[3        [5        S[3        [7        U5      [9        T R:                  5      -  5      5      5      nUSSU2   n[(        R<                  " [7        U5      [7        U5      45      n	[?        U5       H  u  n
u  n  pUSSS2   nUSSS2   nUS   S:w  a=  [(        R@                  SU4   n[(        R@                  US[(        RB                  4   U4   nUS   US   :w  a>  [(        R@                  XS   4   n[(        R@                  XS[(        RB                  4   4   n[D        RF                  " XSS9" U5      nUS-  n[(        RH                  " USS9U	SS2U
4'   M     [(        RJ                  " [(        RL                  " U	5      SS9nX   nX   n	[(        RN                  " U	RI                  SS95      nUU   nUT l(        UT l)        U	T l*        T RW                  TTT RX                  USSS9  T $ )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.

**params : dict, default=None
    Parameters to be passed to the CV 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   Tr   r   r  F)
classifier)split)splitterr   zXParameter "precompute" cannot be an array in %s. Automatically switch to "auto" instead.r$   )r$  r,   c              3     >#    U  Hz  u  p[        [        5      " TU   TU   TU   TU   TS TR                  [        STR                  S-
  5      TR
                  TR                  TR                  TR                  S9v   M|     g7f)Fr   r   )r1   rd   r4   r,   r   r2   r6   r:   N)	r   r  r4   r   r,   r   r2   r6   r:   )rO   traintestr1   r.   r   r/   s      rC   rQ   LarsCV.fit.<locals>.<genexpr>  s      F
  N '(%%$${{At||a/0"00HH  Ns   BBr   Nr[   r   r  r	   )r2   r   r0   r   )-r   r   r   r5   r   r"  r   r   r   r   r   r   r   r(  r   r   r$  r,   r6  r7  ra   concatenaterk   zipuniqueintr   rj   r  r#  rr   	enumerater   r   r   interp1dr  allr   argminalpha_
cv_alphas_	mse_path_r   r2   )r   r.   r/   paramsr"  routed_paramscv_paths
all_alphasstridemse_pathindexr   r   r  this_residuesmaski_best_alpha
best_alphar1   s   ```               @rC   r   
LarsCV.fit  s   6 	&$.T1aN114;;/14;;/ dgg%0+D%B6BM!5r?;M 4%%MM>@D@W@WX D4;;E F
  "xx1M0F0F0L0LMF
 
" ^^Dh$89
YYz*
SCJ%8I8I2J JKLM&)
88S_c(m<=/8/B+E+FAqDbD\F"~HayA~q&y)55!RZZ-!8(!BCbzZ^+v"~5655B

N+C!CD'00J:VMaM!#R!@HQX 0C vvbkk(+"5%
>yyB!78-
 !$!
 			]] 	 	
 rE   c                     [        U R                  R                  S9R                  [	        U R
                  5      [        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   r6  )callercallee)r7  method_mapping)r   r(  r   addr   r"  r   )r   routers     rC   get_metadata_routingLarsCV.get_metadata_routing  sQ      dnn&=&=>BBdgg&(?..eG.L C 
 rE   )rD  r"  rE  r2   r#  rF  r$  )r   r   r   r  r  r   r   r   r   r  r  	parameterr   r4   ra   rz   r  r6   r   r-  r   r   rZ  r  __classcell__r(  s   @rC   r   r     s    FP$

%
%$h4?@m!(AtFCDT"$D  O	""9- O F
 HHUO
 
6
 5n 6n` rE   r   c                       \ rS rSrSr0 \R                  ESS/0ErSrSSSS	S
SS
\R                  " \
5      R                  SSS.
S jrSrg
)LassoLarsCVi'  a  Cross-validated Lasso, using the LARS algorithm.

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

The optimization objective for Lasso is::

(1 / (2 * n_samples)) * ||y - Xw||^2_2 + alpha * ||w||_1

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

Parameters
----------
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).

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

max_iter : int, default=500
    Maximum number of iterations to perform.

precompute : bool or 'auto' , default='auto'
    Whether to use a precomputed Gram matrix to speed up
    calculations. If set to ``'auto'`` let us decide. The Gram matrix
    cannot be passed as argument since we will use only subsets of X.

cv : int, cross-validation generator or an 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.

max_n_alphas : int, default=1000
    The maximum number of points on the path used to compute the
    residuals in the cross-validation.

n_jobs : int or None, 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.

eps : float, default=np.finfo(float).eps
    The machine-precision regularization in the computation of the
    Cholesky diagonal factors. Increase this for very ill-conditioned
    systems. Unlike the ``tol`` parameter in some iterative
    optimization-based algorithms, this parameter does not control
    the tolerance of the optimization.

copy_X : bool, default=True
    If True, X will be copied; else, it may be overwritten.

positive : bool, default=False
    Restrict coefficients to be >= 0. Be aware that you might want to
    remove fit_intercept which is set True by default.
    Under the positive restriction the model coefficients do not converge
    to the ordinary-least-squares solution for small values of alpha.
    Only coefficients up to the smallest alpha value (``alphas_[alphas_ >
    0.].min()`` when fit_path=True) reached by the stepwise Lars-Lasso
    algorithm are typically in congruence with the solution of the
    coordinate descent Lasso estimator.
    As a consequence using LassoLarsCV only makes sense for problems where
    a sparse solution is expected and/or reached.

Attributes
----------
coef_ : array-like of shape (n_features,)
    parameter vector (w in the formulation formula)

intercept_ : float
    independent term in decision function.

coef_path_ : array-like of shape (n_features, n_alphas)
    the varying values of the coefficients along the path

alpha_ : float
    the estimated regularization parameter alpha

alphas_ : array-like of shape (n_alphas,)
    the different values of alpha along the path

cv_alphas_ : array-like of shape (n_cv_alphas,)
    all the values of alpha along the path for the different folds

mse_path_ : array-like of shape (n_folds, n_cv_alphas)
    the mean square error on left-out for each fold along the path
    (alpha values given by ``cv_alphas``)

n_iter_ : array-like or int
    the number of iterations run by Lars with the optimal alpha.

active_ : list of int
    Indices of active variables at the end of the path.

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
--------
lars_path : Compute Least Angle Regression or Lasso
    path using LARS algorithm.
lasso_path : Compute Lasso path with coordinate descent.
Lasso : Linear Model trained with L1 prior as
    regularizer (aka the Lasso).
LassoCV : Lasso linear model with iterative fitting
    along a regularization path.
LassoLars : Lasso model fit with Least Angle Regression a.k.a. Lars.
LassoLarsIC : Lasso model fit with Lars using BIC
    or AIC for model selection.
sklearn.decomposition.sparse_encode : Sparse coding.

Notes
-----
The object solves the same problem as the
:class:`~sklearn.linear_model.LassoCV` object. However, unlike the
:class:`~sklearn.linear_model.LassoCV`, it find the relevant alphas values
by itself. In general, because of this property, it will be more stable.
However, it is more fragile to heavily multicollinear datasets.

It is more efficient than the :class:`~sklearn.linear_model.LassoCV` if
only a small number of features are selected compared to the total number,
for instance if there are very few samples compared to the number of
features.

In `fit`, once the best parameter `alpha` is found through
cross-validation, the model is fit again using the entire training set.

Examples
--------
>>> from sklearn.linear_model import LassoLarsCV
>>> from sklearn.datasets import make_regression
>>> X, y = make_regression(noise=4.0, random_state=0)
>>> reg = LassoLarsCV(cv=5).fit(X, y)
>>> reg.score(X, y)
0.9993
>>> reg.alpha_
np.float64(0.3972)
>>> reg.predict(X[:1,])
array([-78.4831])
r:   r%   r*   TFr=   r$   Nr%  
r   r,   r2   r   r"  r#  r$  r6   r5   r:   c       
         |    Xl         X l        X0l        X@l        XPl        X`l        Xpl        Xl        Xl        Xl	        g rL   ra  )r   r   r,   r2   r   r"  r#  r$  r6   r5   r:   s              rC   r   LassoLarsCV.__init__  s8     + $( rE   )
r5   r"  r6   r   r2   r#  r$  r:   r   r,   )r   r   r   r  r  r   r   r4   ra   rz   r  r6   r   r  r	  rE   rC   r`  r`  '  sj    `D

'
'YK
 F
 HHUO! !rE   r`  c            
       .  ^  \ rS rSr% Sr0 \R                  E\" SS15      /\" \	SSSS9S/S	.Er\
\S
'   S H  r\R                  \5        M      SSSSS\R                  " \5      R"                  SSSS.S jjrU 4S jr\" SS9SS j5       rS rSrU =r$ )LassoLarsICi  a0  Lasso model fit with Lars using BIC or AIC for model selection.

The optimization objective for Lasso is::

(1 / (2 * n_samples)) * ||y - Xw||^2_2 + alpha * ||w||_1

AIC is the Akaike information criterion [2]_ and BIC is the Bayes
Information criterion [3]_. Such criteria are useful to select the value
of the regularization parameter by making a trade-off between the
goodness of fit and the complexity of the model. A good model should
explain well the data while being simple.

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

Parameters
----------
criterion : {'aic', 'bic'}, default='aic'
    The type of criterion to use.

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).

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

precompute : bool, 'auto' or array-like, default='auto'
    Whether to use a precomputed Gram matrix to speed up
    calculations. If set to ``'auto'`` let us decide. The Gram
    matrix can also be passed as argument.

max_iter : int, default=500
    Maximum number of iterations to perform. Can be used for
    early stopping.

eps : float, default=np.finfo(float).eps
    The machine-precision regularization in the computation of the
    Cholesky diagonal factors. Increase this for very ill-conditioned
    systems. Unlike the ``tol`` parameter in some iterative
    optimization-based algorithms, this parameter does not control
    the tolerance of the optimization.

copy_X : bool, default=True
    If True, X will be copied; else, it may be overwritten.

positive : bool, default=False
    Restrict coefficients to be >= 0. Be aware that you might want to
    remove fit_intercept which is set True by default.
    Under the positive restriction the model coefficients do not converge
    to the ordinary-least-squares solution for small values of alpha.
    Only coefficients up to the smallest alpha value (``alphas_[alphas_ >
    0.].min()`` when fit_path=True) reached by the stepwise Lars-Lasso
    algorithm are typically in congruence with the solution of the
    coordinate descent Lasso estimator.
    As a consequence using LassoLarsIC only makes sense for problems where
    a sparse solution is expected and/or reached.

noise_variance : float, default=None
    The estimated noise variance of the data. If `None`, an unbiased
    estimate is computed by an OLS model. However, it is only possible
    in the case where `n_samples > n_features + fit_intercept`.

    .. versionadded:: 1.1

Attributes
----------
coef_ : array-like of shape (n_features,)
    parameter vector (w in the formulation formula)

intercept_ : float
    independent term in decision function.

alpha_ : float
    the alpha parameter chosen by the information criterion

alphas_ : array-like of shape (n_alphas + 1,) or list of such arrays
    Maximum of covariances (in absolute value) at each iteration.
    ``n_alphas`` is either ``max_iter``, ``n_features`` or the
    number of nodes in the path with ``alpha >= alpha_min``, whichever
    is smaller. If a list, it will be of length `n_targets`.

n_iter_ : int
    number of iterations run by lars_path to find the grid of
    alphas.

criterion_ : array-like of shape (n_alphas,)
    The value of the information criteria ('aic', 'bic') across all
    alphas. The alpha which has the smallest information criterion is
    chosen, as specified in [1]_.

noise_variance_ : float
    The estimated noise variance from the data used to compute the
    criterion.

    .. versionadded:: 1.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
--------
lars_path : Compute Least Angle Regression or Lasso
    path using LARS algorithm.
lasso_path : Compute Lasso path with coordinate descent.
Lasso : Linear Model trained with L1 prior as
    regularizer (aka the Lasso).
LassoCV : Lasso linear model with iterative fitting
    along a regularization path.
LassoLars : Lasso model fit with Least Angle Regression a.k.a. Lars.
LassoLarsCV: Cross-validated Lasso, using the LARS algorithm.
sklearn.decomposition.sparse_encode : Sparse coding.

Notes
-----
The number of degrees of freedom is computed as in [1]_.

To have more details regarding the mathematical formulation of the
AIC and BIC criteria, please refer to :ref:`User Guide <lasso_lars_ic>`.

References
----------
.. [1] :arxiv:`Zou, Hui, Trevor Hastie, and Robert Tibshirani.
        "On the degrees of freedom of the lasso."
        The Annals of Statistics 35.5 (2007): 2173-2192.
        <0712.0881>`

.. [2] `Wikipedia entry on the Akaike information criterion
        <https://en.wikipedia.org/wiki/Akaike_information_criterion>`_

.. [3] `Wikipedia entry on the Bayesian information criterion
        <https://en.wikipedia.org/wiki/Bayesian_information_criterion>`_

Examples
--------
>>> from sklearn import linear_model
>>> reg = linear_model.LassoLarsIC(criterion='bic')
>>> X = [[-2, 2], [-1, 1], [0, 0], [1, 1], [2, 2]]
>>> y = [-2.2222, -1.1111, 0, -1.1111, -2.2222]
>>> reg.fit(X, y)
LassoLarsIC(criterion='bic')
>>> print(reg.coef_)
[ 0.  -1.11]
aicbicr   Nr&   r'   )	criterionnoise_variancer   )r   r   r   r   TFr$   r=   )r   r,   r   r2   r6   r5   r:   ri  c                ~    Xl         X l        Xl        XPl        X0l        Xpl        X@l        X`l        SU l        Xl	        g )NT)
rh  r   r:   r2   r,   r5   r   r6   r   ri  )
r   rh  r   r,   r   r2   r6   r5   r:   ri  s
             rC   r   LassoLarsIC.__init__  s:     #*  $,rE   c                 F   > [         TU ]  5       nSUR                  l        U$ r+  r,  r/  s     rC   r-  LassoLarsIC.__sklearn_tags__  r2  rE   r;   c                    Uc  U R                   n[        XUSSS9u  p[        XU R                  US9u  ppEnU R                  n[        UUUUSSSU R                  U R                  U R                  SU R                  S9u  pol
        UR                  S   nU R                  S	:X  a  S
nO5U R                  S:X  a  [        U5      nO[        SU R                  < 35      eUSS2[        R                   4   [        R"                  " X5      -
  n[        R$                  " US
-  SS9n[        R&                  " U
R                  S   [(        S9n[+        U
R,                  5       H}  u  nn[        R.                  " U5      [        R0                  " UR2                  5      R                  :  n[        R4                  " U5      (       d  Md  [        R$                  " U5      UU'   M     Xl        U R8                  c   U R;                  XU R                  S9U l        OU R8                  U l        U[        R                  " S
[        R>                  -  U R<                  -  5      -  XR<                  -  -   X-  -   U l         [        RB                  " U R@                  5      nUU   U l"        U
SS2U4   U l#        U RI                  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,)
    Target values. Will be cast to X's dtype if necessary.

copy_X : bool, default=None
    If provided, this parameter will override the choice
    of copy_X made at instance creation.
    If ``True``, X will be copied; else, it may be overwritten.

Returns
-------
self : object
    Returns an instance of self.
NTr4  r   rS   r*   )
r1   r5   r7   r3   r4   r,   r2   r6   r9   r:   r   rf  r	   rg  z+criterion should be either bic or aic, got r  r   rM   )r:   )%r5   r   r"   r   r   rD   r,   r2   r6   r:   r   rg   rh  r   rA   ra   r   rb   r   rn   r?  r@  rc   r   rz   rN   anyr   ri  _estimate_noise_variancenoise_variance_pi
criterion_rC  rD  r   r   )r   r.   r/   r5   XmeanymeanXstdr1   r   r   r   r@   criterion_factor	residualsresiduals_sum_squaresdegrees_of_freedomr   r   rO  n_bests                       rC   r   LassoLarsIC.fit  sk   , >[[FTaN#3 2 2$
 eD /8LL]]]]0
,J GGAJ	>>U" ^^u$"9~=dnn=OP  am$rvva'<<	 "y!|! <XXj&6&6q&9E .GAt66$<"((4::"6":"::D66$<< %'FF4Lq! / &#'#@#@t}} $A $D  $(#6#6D  q255y4+?+??@@#&:&::;34 	
 4??+fo6	*
E$/rE   c                    UR                   S   UR                   S   U R                  -   ::  a#  [        SU R                  R                   S35      e[        USS9nUR                  X5      R                  U5      n[        R                  " X%-
  S-  5      UR                   S   UR                   S   -
  U R                  -
  -  $ )a  Compute an estimate of the variance with an OLS model.

Parameters
----------
X : ndarray of shape (n_samples, n_features)
    Data to be fitted by the OLS model. We expect the data to be
    centered.

y : ndarray of shape (n_samples,)
    Associated target.

positive : bool, default=False
    Restrict coefficients to be >= 0. This should be inline with
    the `positive` parameter from `LassoLarsIC`.

Returns
-------
noise_variance : float
    An estimator of the noise variance of an OLS model.
r   r   zYou are using z in the case where the number of samples is smaller than the number of features. In this setting, getting a good estimate for the variance of the noise is not possible. Provide an estimate of the noise variance in the constructor.F)r:   r   r	   )
rg   r   rA   r(  r   r!   r   predictra   r   )r   r.   r/   r:   	ols_modely_preds         rC   rp  $LassoLarsIC._estimate_noise_variance	  s    * 771:d&8&888 !8!8 9 :   %heL	q$,,Q/vvqza'(GGAJ#d&8&88
 	
rE   )rD  r   r   r5   rh  rs  r6   r   r   r2   r   ri  rq  r:   r   r,   )rf  rL   )r   r   r   r  r  r  r   r   r   r   r  r  r\  r   ra   rz   r  r6   r   r-  r   r   rp  r  r]  r^  s   @rC   re  re    s    Wr$

*
*$ %01#D!T&A4H$D  E	""9- E
 - HHUO-0
 5X 6Xt"
 "
rE   re  rL   )F)?r  rv   r   mathr   numbersr   r   numpyra   scipyr   r   scipy.linalg.lapackr   baser
   r   r   
exceptionsr   model_selectionr   utilsr   r   r   r   utils._metadata_requestsr   r   r   r   r   utils._param_validationr   r   r   r   utils.parallelr   r   utils.validationr   _baser    r!   r"   r   r  rz   r  r6   rD   rH   rB   r   r  r  r  r   r`  re  r	  rE   rC   <module>r     s      "  % 0 A A + &   T S . , B B'/  jj$jj$zz4 VH%y"**dCh4?@tQV<=ug./0+q$y94@[;!{#K  #'#, i
 

i'&iX zzlxD@Ah4?@tQV<=ug./0+q$y94@[;!{#K #'!. 
[%$[B 	
v'z_^[ _D	p) p)n 
	
q-hyT yx	A!& A!L}
) }
rE   