`L i{ bdZddlZddlmZddlmZmZddlZddl m Z ddl m Z ddl mZmZmZdd lmZdd lmZmZmZdd lmZmZmZdd lmZmZmZmZm Z dd l!m"Z"m#Z#ddl$m%Z%ddl&m'Z'm(Z(dZ)d(dZ* d)dZ+edgejXgeeddddgeeddddgdedhgdgdgdgddddddddddZ-edgdgeeddddgeeddddgddgdgdgdgdgd ddddddddd!d"Z.Gd#d$eee'Z/ d*d%Z0Gd&d'ee'Z1y)+z&Orthogonal matching pursuit algorithmsN)sqrt)IntegralReal)linalg)get_lapack_funcs)MultiOutputMixinRegressorMixin _fit_context)check_cv)Bunchas_float_array check_array)Interval StrOptionsvalidate_params)MetadataRouter MethodMapping_raise_for_params_routing_enabledprocess_routing)Paralleldelayed) 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|r|jd}ntj|}tj|jj }t jd|f\}}td|f\} tj|j|} |} tjd} d} tj|jd}||jdn|}tj||f|j}|rtj|} tjtj tj|j| }|| ks | |d z|kr"t#j$t&t(d n| dkDrtj|ddd| fj|dd|f|| d| f<t j*|d| d| f|| d| fdddd ||| d| fd z}t j,|dd|fd z|z }||kr!t#j$t&t(d nt/||| | f<nt j,|dd|f|d <||j| |j|\|j| <|j|<| || | c| | <| |<|||| c|| <||<| dz } | |d| d| f| d| dd \} }|r | d| | dz f<|tj|ddd| f| z } ||| d z|krn| |k(rn4|r| |d| ddd| f| fS| |d| | fS)aOrthogonal 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. Fnrm2swappotrsrrNdtypeTr stacklevelFtranslower overwrite_b check_finiterrr+r,)copynpasfortranarrayfinfor&epsrget_blas_funcsrdotTemptyarangeshape empty_likeargmaxabswarningswarn prematureRuntimeWarningsolve_triangularnormr)Xyn_nonzero_coefstolcopy_X return_path min_floatr!r"r$alpharesidualgamman_activeindices max_featuresLcoefslamvLkk_s _/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sklearn/linear_model/_omp.py _cholesky_omprX$sV FF3K   a !%%I&&'7!>JD$ QD1HU FF133NEH HHQKEHii #G!$1771:oL , -QWW=A a  iirvvacc8456 >U3Z1_y8 MM)^ B  a<%'VVAa(lO,=,=qCy%IAh  ! "  # #)8)YhY&'(IXI%& "  Qx(*+,1A++a3i(A-1Ci iAF$(IAh !kk!AsF),AdG"&qss8}acc#h"?H qss3x&+Cj%/#hs*1#,8I'73<A  ixi(" #U9H%5Tu q -2E)8)X\) *rvva9H9 ou55 ?tH~2c9   % W Zgix(%9H9 *=xGGgix((22c|r|jdntj|}|s|jjs|j}tj |j j}tjd|f\} } td|f\} tjt|} |} |}d}tjd}d}| t|n|}tj||f|j }d|d<|rtj|} tjtj | }||ks | |d z|kr"t#j$t&t(d n|dkDr||d|f||d|f<tj*|d|d|f||d|fdd d d| ||d|fd z}|||f|z }||kr"t#j$t&t(d n,t-||||f<nt-|||f|d<| ||||\||<||<| |j.||j.|\|j.|<|j.|<| || |c| |<| |<||||c||<||<|d z }| |d|d|f|d|d d\}}|r |d||d z f<tj0|ddd|f|}||z } |2||z }tj2||d|}||z}t!||krn||k(rn |r|| d|ddd|f|fS|| d||fS)aOrthogonal 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. rr r#rNr%g?r.Trr'rFr)r/)r0r1r2flags writeabler3r&r4rr5rr9lenr8r;r<r=r>r?r@rArBrr7r6inner)GramXyrFtol_0rG copy_Gramcopy_XyrIrJr!r"r$rOrKtol_currdeltarMrNrPrQrRrSrTrUrVbetas rW _gram_omprhsz'499S>B,=,=d,CDbhh(( WWY$((I&&'7$AJD$ TG4HUiiD "G EH E HHQKEH #3t9_L , -TZZ@AAdG a  iiu & >U3Z1_y8 MM)^ B  a<%)#yy.%9Ah  ! "  # #)8)YhY&'(IXI%& "  Qx(*+,1AsCx.1$Ci iAF$(IAh !4S>*AdG$(hc$C!XS (,TVVH-=tvvc{(K%x$&&+*1#,8I'73< "3H8 bgA  ixi(" #R ]$E q -2E)8)X\) *vvd1ixi<(%0T  ?  HHHUD(O4E  H8}#  % [ ^gix(%9H9 *=xGGgix((22rYz array-likeleftclosedbooleanauto)rDrErFrG precomputerHrI return_n_iterprefer_skip_nested_validation)rFrGrnrHrIroc Jt|d|}d}|jdk(r|jdd}t|}|jddkDrd}|'|%t t d|jdzd}|||jdkDr t d |d k(r|jd |jdkD}|rtj|j|}tj|}tj|j|} |tj|d zd } nd} t|| ||| |d|S|r@tj|jd|jd|jdf} n1tj|jd|jdf} g} t|jdD]} t||dd| f||||}|rP|\}}}}| dddddt!|f} t#|jD]\}}|d|dz| |d|dz| |f<n |\}}}|| || f<| j%||jddk(r| d } |rtj&| | fStj&| S)a[ 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 `. 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]) rorderr0FrTN皙?>The number of atoms cannot be more than the number of featuresrmrraxis)rFrG norms_squaredrcrdrI)rHrI)rndimreshaper:maxint ValueErrorr1r6r7r2sumorthogonal_mp_gramzerosrangerXr^ enumerateappendsqueeze)rDrErFrGrnrHrIroGrarzcoefn_iterskoutrVidxrRn_iterrNxs rW orthogonal_mpr"s` ASv.A Fvv{ IIb! AAwwqzA~3;c# "23Q7 {3 L  VWWQZ!''!*,  FF133N   a  VVACC^ ?FFAqD2M M! +'#  xxQWWQZ<=xxQWWQZ01G 1771:   qAwV  $' !AsE61jCj()D(1 K !9:>X\9JS8a<(!X56 K!NAsFDaLv  wwqzQ!*zz$((zz$rYneither) r`rarFrGrzrcrdrIro)rFrGrzrcrdrIroc t|d|}tj|}|jdkDr|jddkDrd}|jdk(r|ddtj f}||g}|s|j js|j}||tdt|z}| | td||dkr td ||dkr td ||t|kDr td |rDtjt||jdt|f|j } n9tjt||jdf|j } g} t|jdD]} t||dd| f|||| nd||d |} |rP| \} }}}| dddddt|f} t!|j"D]\}}|d|dz| |d|dz| |f<n | \}}}|| || f<| j%||jddk(r| d} |rtj&| | fStj&| S)ak 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 `. 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]) rrsrTNrvzSGram OMP needs the precomputed norms in order to evaluate the error sum of squares.rzEpsilon cannot be negativez$The number of atoms must be positiverwr%F)rcrdrI)rr1asarrayr{r:newaxisr\r]r0r~r^rrr&rrhrr7rr)r`rarFrGrzrcrdrIrorrrrrVrrRrrNrs rWrrsb t3Y 7D BB ww{rxx{Q  ww!| 2::  ?*OMbhh(( WWY3;cCIo. =0 4   37566 {!+?@@ {T2 L  xxTBHHQKT;4::NxxTBHHQK0 CG 288A;   q!tH  #M! T #   $' !AsE61jCj()D(1 K !9:>X\9JS8a<(!X56 K!NAsFDaLv'* xx{a!*zz$((zz$rYceZdZUdZeeddddgeeddddgdgedhdgd Ze e d <ddd dd d Z e d dZ y)OrthogonalMatchingPursuita Orthogonal Matching Pursuit model (OMP). Read more in the :ref:`User Guide `. 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]) rNrirjrrlrmrFrG fit_interceptrn_parameter_constraintsTc<||_||_||_||_yNr)selfrFrGrrns rW__init__z"OrthogonalMatchingPursuit.__init__s" /*$rYrpc t|||dd\}}|jd}t||d|j|jd\}}}}}}}|j dk(r|ddt jf}|j*|jttd|zd|_ n%|jd|_ n|j|_ |dur/t|||j|jddd\} |_nW|jt j|d zd nd} t!|||j|j| ddd \} |_| j"|_|j'||||S) aFit 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_numericrNr0rvF)rFrGrnrHrorrrx)rarFrGrzrcrdro)rr:rrnrr{r1rrFrGr}r~n_nonzero_coefs_rn_iter_rrr7coef__set_intercept) rrDrE n_featuresX_offsety_offsetX_scaler`rarnorms_sqs rWfitzOrthogonalMatchingPursuit.fitsu"T1addK1WWQZ 6> q$););$7 31h'4 66Q;!RZZ- A    'DHH,<%(C*,<(=q$AD ! XX !$(D !$($8$8D ! 5="/ $ 5 5HH "# E4<04xx/Crvvad+H"4 $ 5 5HH&" # E4<WW  Hh8 rY)__name__ __module__ __qualname____doc__rrrrrdict__annotations__rr rrYrWrrsWt%Xq$vFMq$v6=#!6(+Y7 $D  %5<6<rYrc |r@|j}|j}|j}|j}|rR|jd}||z}||z}|jd}t|d}||z}t|d}||z}t|||dddd} | jdk(r| ddt j f} t j| j|j|z S) 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. rrxFrNT)rFrGrnrHrIr) r0meanrrr{r1rr6r7) X_trainy_trainX_testy_testr0rmax_iterX_meany_meanrRs rW_omp_path_residuesr3sX ,,.,,.1%6&1% u56U3&   E zzQam$ 66%''688 $v --rYceZdZUdZdgdgeeddddgdgedgdgd Zeed <d d dddd d d Z e d dZ dZ y)OrthogonalMatchingPursuitCVayCross-validated Orthogonal Matching Pursuit model (OMP). See glossary entry for :term:`cross-validation estimator`. Read more in the :ref:`User Guide `. 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 ` 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 ` 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]) rlrNrirj cv_objectverboser0rrcvn_jobsrrTFcX||_||_||_||_||_||_yrr)rr0rrrrrs rWrz$OrthogonalMatchingPursuitCV.__init__s/ *    rYrpc  t|dtdd\tddtjd}t rt dfi|}nt}ti|_js` for more details. Returns ------- self : object Returns an instance of self. rTr)rensure_min_featuresF)r0ensure_all_finite) classifier)splitrvr)rrc 3K|]B\}}tt||||jjDywr)rrr0r).0traintestrDrrrEs rW z2OrthogonalMatchingPursuitCV.fit..1s] F t (G& '%%$$ ""  F sAA c3:K|]}|jdyw)rN)r:)rfolds rWrz2OrthogonalMatchingPursuitCV.fit..>s@tTZZ]@sNrxr)rFr)rrrr rrrr splitterrminr}r~r:rrrrr1arrayrargminrrrrr intercept_r) rrDrE fit_paramsr routed_paramscv_pathsmin_early_stopr mse_foldsbest_n_nonzero_coefsomprs ``` @rWrzOrthogonalMatchingPursuitCV.fits6 *dE2T1a4QO1 15E B dgg% 0  +D%F:FM"GM%*_M "== Caggaj()1-qwwqz :  F84;; E F  (rxxJ]-C-C-I-IJ F  @x@@HHCK L4d?N#q( . .A . 6 L  "yyQ)?@1D 4'0,,  #a) YY ..{{   MsG?ct|jjj|jt jdd}|S)ajGet metadata routing of this object. Please check :ref:`User Guide ` on how the routing mechanism works. .. versionadded:: 1.4 Returns ------- routing : MetadataRouter A :class:`~sklearn.utils.metadata_routing.MetadataRouter` encapsulating routing information. )ownerrr)callercallee)rmethod_mapping)r __class__raddrr)rrouters rWget_metadata_routingz0OrthogonalMatchingPursuitCV.get_metadata_routingNsL dnn&=&=>BBWW(?..eG.LC  rY) rrrrrrrrrrr rrrrYrWrr~sk\ #h4?FmT"; $D "5E6ENrYr)NTF)NNTTF)TTd)2rr>mathrnumbersrrnumpyr1scipyrscipy.linalg.lapackrbaser r r model_selectionr utilsr rrutils._param_validationrrrutils.metadata_routingrrrrrutils.parallelrrutils.validationr_baserrr@rXrhndarrayrrrrrrrYrWrs, "0AA&66KK/,( q3p   G3T^jj\$Xq$vFMq$v6= *fX"67+!{# #' "  a  a Hn$Xq$yI4Pq$v6=&-[;!{# #' $  a  a Hk 0.+kf  H.Vc.+crY