
    -ibb                       S r SSKrSSKrSSKJrJr  SSKrSSKJr  SSK	J
r
  SSKJr  SSKJrJr  SS	KJr  SS
KJr  SSKJr  SSKJrJr  SSKJr  SSKJrJrJrJrJ r   SSK!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-J.r.J/r/  SSK0J1r1  SSK2J3r3J4r4  SSK5J6r6J7r7  SSK8J9r9J:r:J;r;J<r<  SSK=J>r>J?r?J@r@  SSKAJBrB  SSKCJDrD  SSKEJFrF  SrGS rHS rI                   S%S jrJS  rK " S! S"\?\@\>5      rL " S# S$\L\?\>5      rMg)&z
Logistic Regression
    N)IntegralReal)effective_n_jobs)optimize)get_scorer_names   )HalfBinomialLossHalfMultinomialLoss)_fit_context)
get_scorer)check_cv)LabelBinarizerLabelEncoder)_fit_liblinear)Bunchcheck_arraycheck_consistent_lengthcheck_random_statecompute_class_weight)HiddenInterval
StrOptions)	row_normssoftmax)"_get_additional_lbfgs_options_dict)MetadataRouterMethodMapping_raise_for_params_routing_enabledprocess_routing)check_classification_targets)_check_optimize_result
_newton_cg)Paralleldelayed)_check_method_params_check_sample_weightcheck_is_fittedvalidate_data   )BaseEstimatorLinearClassifierMixinSparseCoefMixin)NewtonCholeskySolver)LinearModelLoss)
sag_solverzPlease also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regressionc                     U S;  a  US;  a  [        SU  SU S35      eU S:w  a  U(       a  [        SU  SU 35      eUS:X  a  U S	:w  a  [        S
U  S35      eU S:X  a  Uc  [        S5      eU $ )N)	liblinearsaga)l2NzSolver z+ supports only 'l2' or None penalties, got z	 penalty.r2   z$ supports only dual=False, got dual=
elasticnetr3   z;Only 'saga' solver supports elasticnet penalty, got solver=.z6penalty=None is not supported for the liblinear solver
ValueError)solverpenaltyduals      Q/var/www/html/venv/lib/python3.13/site-packages/sklearn/linear_model/_logistic.py_check_solverr=   >   s    **wl/JfXH	 R 
 	
 76(*NtfUVV,6V#3I&QRS
 	
 QRRM    c                 n    U S:X  a  US;   a  Sn OUS:  a  Sn OSn U S:X  a  US;   a  [        SU-  5      eU $ )zComputes the multi class type, either "multinomial" or "ovr".

For `n_classes` > 2 and a solver that supports it, returns "multinomial".
For all other cases, in particular binary classification, return "ovr".
auto)r2   ovrr   multinomialz1Solver %s does not support a multinomial backend.r7   )multi_classr9   	n_classess      r<   _check_multi_classrE   R   sP     f^#K]'KKm#.(@LvUVVr>   c                 0   [        U[        R                  5      (       a  [        R                  " SSU5      n[        XU5      nU(       a3  [        U S[        R                  US;  S9n [        USSS9n[        X5        U R                  u  nn[        R                  " U5      n[        U5      n[        X[        U5      5      nUc&  US	:w  a   UR                  S
:  a  [        S5      eUS   nUc  U
b  [!        UX R"                  SS9n[%        5       n[        U
[&        5      (       d	  US	:X  a&  U
b#  [)        U
UUUS9nUUUR+                  U5         -  nUS:X  a  [        R,                  " U[/        U5      -   U R"                  S9nX:H  n[        R0                  " UR                  U R"                  S9nUS:X  a  [        R2                  " SS/5      nSUU) '   O[        R2                  " SS/5      nSUU) '   U
S:X  a#  [)        U
UUUS9nUUUR+                  U5         -  nOUS;   a4  [%        5       nUR+                  U5      R5                  U R"                  SS9nOI[7        5       nUR+                  U5      nUR                  S   S:X  a  [        R8                  " SU-
  U/5      n[        R,                  " UR                  U[/        U5      -   4SU R"                  S9nUS;   a  Uc  UO[        R:                  " U5      n U	Gb'  US:X  aQ  U	R                  UUR                  4;  a%  [        SU	R                  UUR                  4-  5      eU	USU	R                  & OUR                  n!U!S
:X  a  Sn!U	R                  S   U!:w  d  U	R                  S   UUS-   4;  aE  [        SU	R                  S   U	R                  S   UR                  UUR                  US-   4-  5      eU!S:X  a.  U	* USSU	R                  S   24'   U	USSU	R                  S   24'   OU	USS2SU	R                  S   24'   US	:X  a~  US;   a  UR=                  SS9n[?        [A        UR                  S 9US!9n"Wn#US":X  a  U"RB                  n$O*US#:X  a$  U"RD                  n$U"RF                  n%U"RH                  n&S$URJ                  0n'OWn#US":X  a  [?        [M        5       US!9n"U"RB                  n$OUUS#:X  a7  [?        [M        5       US!9n"U"RD                  n$U"RF                  n%U"RH                  n&OUS%:X  a  [?        [M        5       US!9n"S$[        RN                  " USS&90n'[Q        5       n([        R,                  " [        U5      [        RR                  S9n)[U        U5       GH  u  n*n+US":X  a  S'U+W -  -  n,/ S(Q[        RV                  " [        R2                  " / S)Q5      U5         n-[X        RZ                  " W$US*SU U#UU,U4US+US,[        R\                  " [^        5      R`                  -  S-.[c        S.U-5      ES/9n.[e        UU.U[f        S09n/U.Rh                  U.Rj                  n"nGOUS#:X  a$  S'U+W -  -  n,U U#UU,U4n0[m        W&W$W%UU0UUUS19u  nn/GOZUS%:X  a6  S'U+W -  -  n,[o        UW"U,UUUUS29n1U1Rq                  U U#US39nU1Rr                  n/GOUS:X  a  [        U5      S
:  a  [t        Rv                  " S4[x        5        [{        U U#U+UUSUUUUUUUS59u  n2n3n/U(       a'  [        R|                  " U2R=                  5       U3/5      nOU2R=                  5       nU/R                  5       n/OUS6;   ar  US	:X  a  U#R5                  U R"                  SS9n#S	n"OS7n"US8:X  a  Sn4S'U+-  n5O!US9:X  a  S'U+-  n4Sn5OS'U+-  SU-
  -  n4S'U+-  U-  n5[        U U#UU"U4U5UUUUSUU'US::H  S;9u  nn/n'O[        S<U-  5      eUS	:X  aw  [        S
UR                  5      n!US;   a  [        R                  " UU!S4SS9n6OUn6U!S
:X  a  U6S   [        R                  SS24   n6U(R                  U6R                  5       5        OU(R                  UR                  5       5        U/U)U*'   GM     [        R2                  " U(5      [        R2                  " U5      U)4$ )=a  Compute a Logistic Regression model for a list of regularization
parameters.

This is an implementation that uses the result of the previous model
to speed up computations along the set of solutions, making it faster
than sequentially calling LogisticRegression for the different parameters.
Note that there will be no speedup with liblinear solver, since it does
not handle warm-starting.

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

Parameters
----------
X : {array-like, sparse matrix} of shape (n_samples, n_features)
    Input data.

y : array-like of shape (n_samples,) or (n_samples, n_targets)
    Input data, target values.

pos_class : int, default=None
    The class with respect to which we perform a one-vs-all fit.
    If None, then it is assumed that the given problem is binary.

Cs : int or array-like of shape (n_cs,), default=10
    List of values for the regularization parameter or integer specifying
    the number of regularization parameters that should be used. In this
    case, the parameters will be chosen in a logarithmic scale between
    1e-4 and 1e4.

fit_intercept : bool, default=True
    Whether to fit an intercept for the model. In this case the shape of
    the returned array is (n_cs, n_features + 1).

max_iter : int, default=100
    Maximum number of iterations for the solver.

tol : float, default=1e-4
    Stopping criterion. For the newton-cg and lbfgs solvers, the iteration
    will stop when ``max{|g_i | i = 1, ..., n} <= tol``
    where ``g_i`` is the i-th component of the gradient.

verbose : int, default=0
    For the liblinear and lbfgs solvers set verbose to any positive
    number for verbosity.

solver : {'lbfgs', 'liblinear', 'newton-cg', 'newton-cholesky', 'sag', 'saga'},             default='lbfgs'
    Numerical solver to use.

coef : array-like of shape (n_features,), default=None
    Initialization value for coefficients of logistic regression.
    Useless for liblinear solver.

class_weight : dict or 'balanced', default=None
    Weights associated with classes in the form ``{class_label: weight}``.
    If not given, all classes are supposed to have weight one.

    The "balanced" mode uses the values of y to automatically adjust
    weights inversely proportional to class frequencies in the input data
    as ``n_samples / (n_classes * np.bincount(y))``.

    Note that these weights will be multiplied with sample_weight (passed
    through the fit method) if sample_weight is specified.

dual : bool, default=False
    Dual or primal formulation. Dual formulation is only implemented for
    l2 penalty with liblinear solver. Prefer dual=False when
    n_samples > n_features.

penalty : {'l1', 'l2', 'elasticnet'}, default='l2'
    Used to specify the norm used in the penalization. The 'newton-cg',
    'sag' and 'lbfgs' solvers support only l2 penalties. 'elasticnet' is
    only supported by the 'saga' solver.

intercept_scaling : float, default=1.
    Useful only when the solver `liblinear` is used
    and `self.fit_intercept` is set to `True`. In this case, `x` becomes
    `[x, self.intercept_scaling]`,
    i.e. a "synthetic" feature with constant value equal to
    `intercept_scaling` is appended to the instance vector.
    The intercept becomes
    ``intercept_scaling * synthetic_feature_weight``.

    .. note::
        The synthetic feature weight is subject to L1 or L2
        regularization as all other features.
        To lessen the effect of regularization on synthetic feature weight
        (and therefore on the intercept) `intercept_scaling` has to be increased.

multi_class : {'ovr', 'multinomial', 'auto'}, default='auto'
    If the option chosen is 'ovr', then a binary problem is fit for each
    label. For 'multinomial' the loss minimised is the multinomial loss fit
    across the entire probability distribution, *even when the data is
    binary*. 'multinomial' is unavailable when solver='liblinear'.
    'auto' selects 'ovr' if the data is binary, or if solver='liblinear',
    and otherwise selects 'multinomial'.

    .. versionadded:: 0.18
       Stochastic Average Gradient descent solver for 'multinomial' case.
    .. versionchanged:: 0.22
        Default changed from 'ovr' to 'auto' in 0.22.

random_state : int, RandomState instance, default=None
    Used when ``solver`` == 'sag', 'saga' or 'liblinear' to shuffle the
    data. See :term:`Glossary <random_state>` for details.

check_input : bool, default=True
    If False, the input arrays X and y will not be checked.

max_squared_sum : float, default=None
    Maximum squared sum of X over samples. Used only in SAG solver.
    If None, it will be computed, going through all the samples.
    The value should be precomputed to speed up cross validation.

sample_weight : array-like of shape(n_samples,), default=None
    Array of weights that are assigned to individual samples.
    If not provided, then each sample is given unit weight.

l1_ratio : float, default=None
    The Elastic-Net mixing parameter, with ``0 <= l1_ratio <= 1``. Only
    used if ``penalty='elasticnet'``. Setting ``l1_ratio=0`` is equivalent
    to using ``penalty='l2'``, while setting ``l1_ratio=1`` is equivalent
    to using ``penalty='l1'``. For ``0 < l1_ratio <1``, the penalty is a
    combination of L1 and L2.

n_threads : int, default=1
   Number of OpenMP threads to use.

Returns
-------
coefs : ndarray of shape (n_cs, n_features) or (n_cs, n_features + 1)
    List of coefficients for the Logistic Regression model. If
    fit_intercept is set to True then the second dimension will be
    n_features + 1, where the last item represents the intercept. For
    ``multiclass='multinomial'``, the shape is (n_classes, n_cs,
    n_features) or (n_classes, n_cs, n_features + 1).

Cs : ndarray
    Grid of Cs used for cross-validation.

n_iter : array of shape (n_cs,)
    Actual number of iteration for each Cs.

Notes
-----
You might get slightly different results with the solver liblinear than
with the others since this uses LIBLINEAR which penalizes the intercept.

.. versionchanged:: 0.19
    The "copy" parameter was removed.
   csrr2   sagr3   )accept_sparsedtypeaccept_large_sparseFN)	ensure_2drM   rB   r   z&To fit OvR, use the pos_class argumentr*   T)rM   copyclassesysample_weightrA   rM   r2         r           balanced)rK   r3   lbfgs	newton-cgnewton-choleskyrP   F)orderrM   rZ   r[   r\   z;Initialization coef is of shape %d, expected shape %d or %dzMInitialization coef is of shape (%d, %d), expected shape (%d, %d) or (%d, %d))r_   )rD   )	base_lossfit_interceptrZ   r[   coefr\   axis      ?)rV   2   r*   d   e   )r   r*   r      zL-BFGS-Brg   @   )maxitermaxlsgtolftoliprint)methodjacargsoptions)extra_warning_msg)	grad_hessfuncgradx0rs   rl   tolverbose)rc   linear_lossl2_reg_strengthrz   max_iter	n_threadsr{   )XrS   rT     Using the 'liblinear' solver for multiclass classification is deprecated. An error will be raised in 1.8. Either use another solver which supports the multinomial loss or wrap the estimator in a OneVsRestClassifier to keep applying a one-versus-rest scheme.rT   rK   r3   logl1r4   r3   )is_sagazRsolver must be one of {'liblinear', 'lbfgs', 'newton-cg', 'sag'}, got '%s' instead)F
isinstancenumbersr   nplogspacer=   r   float64r   shapeuniquer   rE   lensizer8   r'   rM   r   dictr   fit_transformzerosintonesarrayastyper   hstacksumravelr/   r
   loss_gradientlossgradientgradient_hessian_productTr	   expand_dimslistint32	enumeratesearchsortedr   minimizefinfofloatepsr   r"    _LOGISTIC_SOLVER_CONVERGENCE_MSGxfunr#   r.   solve	iterationwarningswarnFutureWarningr   concatenateitemr0   maxreshapenewaxisappendrP   )7r   rS   	pos_classCsrb   r~   rz   r{   r9   rc   class_weightr;   r:   intercept_scalingrC   random_statecheck_inputmax_squared_sumrT   l1_ratior   	n_samples
n_featuresrR   leclass_weight_w0masky_binmask_classesY_multilbinsw_sumrD   r   targetrw   rx   hesswarm_start_sagcoefsn_iteriCr}   rp   opt_resn_iter_irs   solcoef_
intercept_alphabetamulti_w0s7                                                          r<   _logistic_regression_pathr   d   s   \ "g&&''[[Q#6D1F ** &.J J	
 U$7%GGIziilG%l3L$[#g,GK[M9<<!EFFAJ	 L$<,]AWWSWX
 
B,%%}$)A,'Qm
 	r'7'7':;; eXXj3}#55QWWE~qww/[ 88RG,LE4%L 88QF+LE4%L :%0$+	M ]2+;+;E+BCCM MM
 B&&q)00u0EG "#D((+G}}Q1$))Q['$:;XX\\:M(::;3agg
 :: ,39N%yyRWW 55 Qyy*bgg67  #B{O  IA~	zz!}	)TZZ]QC . !1 

1

1""Q	  A~*.1o

1o%&)-1o

1o%&)-1o

1o%&m#>>
 $B)GLLA'
 W%%D{"99D==D00D "$$W"*,MD %%D{""*,MD 99D==D00D(("*,MD !"..!"<=FEXXc"gRXX.F"1W!QZ0O* 6@F ''!K'%!4!44	
 96JG ."B	H yy'++B{"!QZ0Ov}oyID% 	LB ((!QZ0O&  /!#C Q&FB}}H{"7|a
 " !+	  ^^U[[]J$?@[[]  }}H&m+qwwU;$$QwDaqQ\2a8++56),(B.$ 8:@A 
 -'Aw||,IBB::b9b/EA~#A;rzz1}5LL)LL#q	] ` 88E?BHHRL&00r>   c          	         X   nX   nX   nX   nSu  nnUb  [        UU 5      nUU   nUU   n[        UU40 SU_SU_SU_SU_SU_SU
_S	U_S
U_SU	_SU_SU_SU_SU_SU_SS_SU_SU_6u  nnn[        UUS9nUS:X  a  [        R                  " SS/5      Ul        O0US:X  a  [        R                  " U5      Ul        O[        SU-  5      eUb8  UU:H  n[        R                  " UR                  [        R                  S9nSUU) '   [        5       n [        U5      nU H  n!US:X  a  U![        R                  SS24   n!U(       a  U!SS2SS24   Ul        U!SS2S4   Ul        OU!Ul        SUl        Uc"  U R!                  UR#                  UUUS95        My  U=(       d    0 n[%        U UUS9nU R!                  U" UUU40 UD65        M     UU[        R                  " U 5      U4$ ) aB  Computes scores across logistic_regression_path

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

y : array-like of shape (n_samples,) or (n_samples, n_targets)
    Target labels.

train : list of indices
    The indices of the train set.

test : list of indices
    The indices of the test set.

pos_class : int
    The class with respect to which we perform a one-vs-all fit.
    If None, then it is assumed that the given problem is binary.

Cs : int or list of floats
    Each of the values in Cs describes the inverse of
    regularization strength. If Cs is as an int, then a grid of Cs
    values are chosen in a logarithmic scale between 1e-4 and 1e4.

scoring : str, callable or None
    The scoring method to use for cross-validation. Options:

    - str: see :ref:`scoring_string_names` for options.
    - callable: a scorer callable object (e.g., function) with signature
      ``scorer(estimator, X, y)``. See :ref:`scoring_callable` for details.
    - `None`: :ref:`accuracy <accuracy_score>` is used.

fit_intercept : bool
    If False, then the bias term is set to zero. Else the last
    term of each coef_ gives us the intercept.

max_iter : int
    Maximum number of iterations for the solver.

tol : float
    Tolerance for stopping criteria.

class_weight : dict or 'balanced'
    Weights associated with classes in the form ``{class_label: weight}``.
    If not given, all classes are supposed to have weight one.

    The "balanced" mode uses the values of y to automatically adjust
    weights inversely proportional to class frequencies in the input data
    as ``n_samples / (n_classes * np.bincount(y))``

    Note that these weights will be multiplied with sample_weight (passed
    through the fit method) if sample_weight is specified.

verbose : int
    For the liblinear and lbfgs solvers set verbose to any positive
    number for verbosity.

solver : {'lbfgs', 'liblinear', 'newton-cg', 'newton-cholesky', 'sag', 'saga'}
    Decides which solver to use.

penalty : {'l1', 'l2', 'elasticnet'}
    Used to specify the norm used in the penalization. The 'newton-cg',
    'sag' and 'lbfgs' solvers support only l2 penalties. 'elasticnet' is
    only supported by the 'saga' solver.

dual : bool
    Dual or primal formulation. Dual formulation is only implemented for
    l2 penalty with liblinear solver. Prefer dual=False when
    n_samples > n_features.

intercept_scaling : float
    Useful only when the solver `liblinear` is used
    and `self.fit_intercept` is set to `True`. In this case, `x` becomes
    `[x, self.intercept_scaling]`,
    i.e. a "synthetic" feature with constant value equal to
    `intercept_scaling` is appended to the instance vector.
    The intercept becomes
    ``intercept_scaling * synthetic_feature_weight``.

    .. note::
        The synthetic feature weight is subject to L1 or L2
        regularization as all other features.
        To lessen the effect of regularization on synthetic feature weight
        (and therefore on the intercept) `intercept_scaling` has to be increased.

multi_class : {'auto', 'ovr', 'multinomial'}
    If the option chosen is 'ovr', then a binary problem is fit for each
    label. For 'multinomial' the loss minimised is the multinomial loss fit
    across the entire probability distribution, *even when the data is
    binary*. 'multinomial' is unavailable when solver='liblinear'.

random_state : int, RandomState instance
    Used when ``solver`` == 'sag', 'saga' or 'liblinear' to shuffle the
    data. See :term:`Glossary <random_state>` for details.

max_squared_sum : float
    Maximum squared sum of X over samples. Used only in SAG solver.
    If None, it will be computed, going through all the samples.
    The value should be precomputed to speed up cross validation.

sample_weight : array-like of shape(n_samples,)
    Array of weights that are assigned to individual samples.
    If not provided, then each sample is given unit weight.

l1_ratio : float
    The Elastic-Net mixing parameter, with ``0 <= l1_ratio <= 1``. Only
    used if ``penalty='elasticnet'``. Setting ``l1_ratio=0`` is equivalent
    to using ``penalty='l2'``, while setting ``l1_ratio=1`` is equivalent
    to using ``penalty='l1'``. For ``0 < l1_ratio <1``, the penalty is a
    combination of L1 and L2.

score_params : dict
    Parameters to pass to the `score` method of the underlying scorer.

Returns
-------
coefs : ndarray of shape (n_cs, n_features) or (n_cs, n_features + 1)
    List of coefficients for the Logistic Regression model. If
    fit_intercept is set to True then the second dimension will be
    n_features + 1, where the last item represents the intercept.

Cs : ndarray
    Grid of Cs used for cross-validation.

scores : ndarray of shape (n_cs,)
    Scores obtained for each Cs.

n_iter : ndarray of shape(n_cs,)
    Actual number of iteration for each Cs.
)NNNr   r   rb   r9   r~   r   r   rC   rz   r{   r;   r:   r   r   r   Fr   rT   )r9   rC   rA   rV   r*   rB   z7multi_class should be either multinomial or ovr, got %drU   rW   rX   r   )r   paramsindices)r'   r   LogisticRegressionr   r   classes_r   r8   r   r   r   r   r   r   r   r   r   scorer&   )"r   rS   traintestr   r   scoringrb   r~   rz   r   r{   r9   r:   r;   r   rC   r   r   rT   r   score_paramsX_trainX_testy_trainy_testsw_trainsw_testr   r   log_regr   scoresws"                                     r<   _log_reg_scoring_pathr   Y  sy   x hGWFhGWF"Hg ,]A> '%1  	
 $   "        ,  "!" #$ (%& 'E2v, !KHG e88RG,		%99W-ES
 	
 "RZZ8uVF!G%"**a- Aa"fIGM!"1b5GGM!$G?MM'--g-NO'-2L/!LRVWLMM''66J\JK   "bhhv&..r>   c                     ^  \ rS rSr% Sr\" 1 Sk5      S/S/\" \SSSS9/\" \SSS	S9/S/\" \SSS
S9/\\" S15      S/S/\" 1 Sk5      /\" \	SSSS9/S/S/S\	/\" \SSSS9S/\" 1 Sk5      \
" \" S15      5      /S.r\\S'    S#SSSSSSSSSSSSSSS.S jjr\" SS9S$S j5       rU 4S jrS  rU 4S! jrS"rU =r$ )%r   i=  a0  
Logistic Regression (aka logit, MaxEnt) classifier.

This class implements regularized logistic regression using the
'liblinear' library, 'newton-cg', 'sag', 'saga' and 'lbfgs' solvers. **Note
that regularization is applied by default**. It can handle both dense
and sparse input. Use C-ordered arrays or CSR matrices containing 64-bit
floats for optimal performance; any other input format will be converted
(and copied).

The 'newton-cg', 'sag', and 'lbfgs' solvers support only L2 regularization
with primal formulation, or no regularization. The 'liblinear' solver
supports both L1 and L2 regularization, with a dual formulation only for
the L2 penalty. The Elastic-Net regularization is only supported by the
'saga' solver.

For :term:`multiclass` problems, all solvers but 'liblinear' optimize the
(penalized) multinomial loss. 'liblinear' only handle binary classification but can
be extended to handle multiclass by using
:class:`~sklearn.multiclass.OneVsRestClassifier`.

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

Parameters
----------
penalty : {'l1', 'l2', 'elasticnet', None}, default='l2'
    Specify the norm of the penalty:

    - `None`: no penalty is added;
    - `'l2'`: add a L2 penalty term and it is the default choice;
    - `'l1'`: add a L1 penalty term;
    - `'elasticnet'`: both L1 and L2 penalty terms are added.

    .. warning::
       Some penalties may not work with some solvers. See the parameter
       `solver` below, to know the compatibility between the penalty and
       solver.

    .. versionadded:: 0.19
       l1 penalty with SAGA solver (allowing 'multinomial' + L1)

dual : bool, default=False
    Dual (constrained) or primal (regularized, see also
    :ref:`this equation <regularized-logistic-loss>`) formulation. Dual formulation
    is only implemented for l2 penalty with liblinear solver. Prefer dual=False when
    n_samples > n_features.

tol : float, default=1e-4
    Tolerance for stopping criteria.

C : float, default=1.0
    Inverse of regularization strength; must be a positive float.
    Like in support vector machines, smaller values specify stronger
    regularization.

fit_intercept : bool, default=True
    Specifies if a constant (a.k.a. bias or intercept) should be
    added to the decision function.

intercept_scaling : float, default=1
    Useful only when the solver `liblinear` is used
    and `self.fit_intercept` is set to `True`. In this case, `x` becomes
    `[x, self.intercept_scaling]`,
    i.e. a "synthetic" feature with constant value equal to
    `intercept_scaling` is appended to the instance vector.
    The intercept becomes
    ``intercept_scaling * synthetic_feature_weight``.

    .. note::
        The synthetic feature weight is subject to L1 or L2
        regularization as all other features.
        To lessen the effect of regularization on synthetic feature weight
        (and therefore on the intercept) `intercept_scaling` has to be increased.

class_weight : dict or 'balanced', default=None
    Weights associated with classes in the form ``{class_label: weight}``.
    If not given, all classes are supposed to have weight one.

    The "balanced" mode uses the values of y to automatically adjust
    weights inversely proportional to class frequencies in the input data
    as ``n_samples / (n_classes * np.bincount(y))``.

    Note that these weights will be multiplied with sample_weight (passed
    through the fit method) if sample_weight is specified.

    .. versionadded:: 0.17
       *class_weight='balanced'*

random_state : int, RandomState instance, default=None
    Used when ``solver`` == 'sag', 'saga' or 'liblinear' to shuffle the
    data. See :term:`Glossary <random_state>` for details.

solver : {'lbfgs', 'liblinear', 'newton-cg', 'newton-cholesky', 'sag', 'saga'},             default='lbfgs'

    Algorithm to use in the optimization problem. Default is 'lbfgs'.
    To choose a solver, you might want to consider the following aspects:

    - For small datasets, 'liblinear' is a good choice, whereas 'sag'
      and 'saga' are faster for large ones;
    - For :term:`multiclass` problems, all solvers except 'liblinear' minimize the
      full multinomial loss;
    - 'liblinear' can only handle binary classification by default. To apply a
      one-versus-rest scheme for the multiclass setting one can wrap it with the
      :class:`~sklearn.multiclass.OneVsRestClassifier`.
    - 'newton-cholesky' is a good choice for
      `n_samples` >> `n_features * n_classes`, especially with one-hot encoded
      categorical features with rare categories. Be aware that the memory usage
      of this solver has a quadratic dependency on `n_features * n_classes`
      because it explicitly computes the full Hessian matrix.

    .. warning::
       The choice of the algorithm depends on the penalty chosen and on
       (multinomial) multiclass support:

       ================= ============================== ======================
       solver            penalty                        multinomial multiclass
       ================= ============================== ======================
       'lbfgs'           'l2', None                     yes
       'liblinear'       'l1', 'l2'                     no
       'newton-cg'       'l2', None                     yes
       'newton-cholesky' 'l2', None                     yes
       'sag'             'l2', None                     yes
       'saga'            'elasticnet', 'l1', 'l2', None yes
       ================= ============================== ======================

    .. note::
       'sag' and 'saga' fast convergence is only guaranteed on features
       with approximately the same scale. You can preprocess the data with
       a scaler from :mod:`sklearn.preprocessing`.

    .. seealso::
       Refer to the :ref:`User Guide <Logistic_regression>` for more
       information regarding :class:`LogisticRegression` and more specifically the
       :ref:`Table <logistic_regression_solvers>`
       summarizing solver/penalty supports.

    .. versionadded:: 0.17
       Stochastic Average Gradient (SAG) descent solver. Multinomial support in
       version 0.18.
    .. versionadded:: 0.19
       SAGA solver.
    .. versionchanged:: 0.22
       The default solver changed from 'liblinear' to 'lbfgs' in 0.22.
    .. versionadded:: 1.2
       newton-cholesky solver. Multinomial support in version 1.6.

max_iter : int, default=100
    Maximum number of iterations taken for the solvers to converge.

multi_class : {'auto', 'ovr', 'multinomial'}, default='auto'
    If the option chosen is 'ovr', then a binary problem is fit for each
    label. For 'multinomial' the loss minimised is the multinomial loss fit
    across the entire probability distribution, *even when the data is
    binary*. 'multinomial' is unavailable when solver='liblinear'.
    'auto' selects 'ovr' if the data is binary, or if solver='liblinear',
    and otherwise selects 'multinomial'.

    .. versionadded:: 0.18
       Stochastic Average Gradient descent solver for 'multinomial' case.
    .. versionchanged:: 0.22
        Default changed from 'ovr' to 'auto' in 0.22.
    .. deprecated:: 1.5
       ``multi_class`` was deprecated in version 1.5 and will be removed in 1.8.
       From then on, the recommended 'multinomial' will always be used for
       `n_classes >= 3`.
       Solvers that do not support 'multinomial' will raise an error.
       Use `sklearn.multiclass.OneVsRestClassifier(LogisticRegression())` if you
       still want to use OvR.

verbose : int, default=0
    For the liblinear and lbfgs solvers set verbose to any positive
    number for verbosity.

warm_start : bool, default=False
    When set to True, reuse the solution of the previous call to fit as
    initialization, otherwise, just erase the previous solution.
    Useless for liblinear solver. See :term:`the Glossary <warm_start>`.

    .. versionadded:: 0.17
       *warm_start* to support *lbfgs*, *newton-cg*, *sag*, *saga* solvers.

n_jobs : int, default=None
    Number of CPU cores used when parallelizing over classes if
    multi_class='ovr'". This parameter is ignored when the ``solver`` is
    set to 'liblinear' regardless of whether 'multi_class' is specified or
    not. ``None`` means 1 unless in a :obj:`joblib.parallel_backend`
    context. ``-1`` means using all processors.
    See :term:`Glossary <n_jobs>` for more details.

l1_ratio : float, default=None
    The Elastic-Net mixing parameter, with ``0 <= l1_ratio <= 1``. Only
    used if ``penalty='elasticnet'``. Setting ``l1_ratio=0`` is equivalent
    to using ``penalty='l2'``, while setting ``l1_ratio=1`` is equivalent
    to using ``penalty='l1'``. For ``0 < l1_ratio <1``, the penalty is a
    combination of L1 and L2.

Attributes
----------

classes_ : ndarray of shape (n_classes, )
    A list of class labels known to the classifier.

coef_ : ndarray of shape (1, n_features) or (n_classes, n_features)
    Coefficient of the features in the decision function.

    `coef_` is of shape (1, n_features) when the given problem is binary.
    In particular, when `multi_class='multinomial'`, `coef_` corresponds
    to outcome 1 (True) and `-coef_` corresponds to outcome 0 (False).

intercept_ : ndarray of shape (1,) or (n_classes,)
    Intercept (a.k.a. bias) added to the decision function.

    If `fit_intercept` is set to False, the intercept is set to zero.
    `intercept_` is of shape (1,) when the given problem is binary.
    In particular, when `multi_class='multinomial'`, `intercept_`
    corresponds to outcome 1 (True) and `-intercept_` corresponds to
    outcome 0 (False).

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

n_iter_ : ndarray of shape (n_classes,) or (1, )
    Actual number of iterations for all classes. If binary or multinomial,
    it returns only 1 element. For liblinear solver, only the maximum
    number of iteration across all classes is given.

    .. versionchanged:: 0.20

        In SciPy <= 1.0.0 the number of lbfgs iterations may exceed
        ``max_iter``. ``n_iter_`` will now report at most ``max_iter``.

See Also
--------
SGDClassifier : Incrementally trained logistic regression (when given
    the parameter ``loss="log_loss"``).
LogisticRegressionCV : Logistic regression with built-in cross validation.

Notes
-----
The underlying C implementation uses a random number generator to
select features when fitting the model. It is thus not uncommon,
to have slightly different results for the same input data. If
that happens, try with a smaller tol parameter.

Predict output may not match that of standalone liblinear in certain
cases. See :ref:`differences from liblinear <liblinear_differences>`
in the narrative documentation.

References
----------

L-BFGS-B -- Software for Large-scale Bound-constrained Optimization
    Ciyou Zhu, Richard Byrd, Jorge Nocedal and Jose Luis Morales.
    http://users.iems.northwestern.edu/~nocedal/lbfgsb.html

LIBLINEAR -- A Library for Large Linear Classification
    https://www.csie.ntu.edu.tw/~cjlin/liblinear/

SAG -- Mark Schmidt, Nicolas Le Roux, and Francis Bach
    Minimizing Finite Sums with the Stochastic Average Gradient
    https://hal.inria.fr/hal-00860051/document

SAGA -- Defazio, A., Bach F. & Lacoste-Julien S. (2014).
        :arxiv:`"SAGA: A Fast Incremental Gradient Method With Support
        for Non-Strongly Convex Composite Objectives" <1407.0202>`

Hsiang-Fu Yu, Fang-Lan Huang, Chih-Jen Lin (2011). Dual coordinate descent
    methods for logistic regression and maximum entropy models.
    Machine Learning 85(1-2):41-75.
    https://www.csie.ntu.edu.tw/~cjlin/papers/maxent_dual.pdf

Examples
--------
>>> from sklearn.datasets import load_iris
>>> from sklearn.linear_model import LogisticRegression
>>> X, y = load_iris(return_X_y=True)
>>> clf = LogisticRegression(random_state=0).fit(X, y)
>>> clf.predict(X[:2, :])
array([0, 0])
>>> clf.predict_proba(X[:2, :])
array([[9.82e-01, 1.82e-02, 1.44e-08],
       [9.72e-01, 2.82e-02, 3.02e-08]])
>>> clf.score(X, y)
0.97

For a comparison of the LogisticRegression with other classifiers see:
:ref:`sphx_glr_auto_examples_classification_plot_classification_probability.py`.
>   r   r4   r5   Nbooleanr   leftclosedrightneitherrY   r   >   rK   r3   rZ   r2   r[   r\   r{   r*   both>   rA   r@   rB   
deprecated)r:   r;   rz   r   rb   r   r   r   r9   r~   r{   
warm_startn_jobsr   rC   _parameter_constraintsF-C6?rf   TrZ   rh   )r;   rz   r   rb   r   r   r   r9   r~   rC   r{   r   r   r   c                    Xl         X l        X0l        X@l        XPl        X`l        Xpl        Xl        Xl        Xl	        Xl
        Xl        Xl        Xl        Xl        g N)r:   r;   rz   r   rb   r   r   r   r9   r~   rC   r{   r   r   r   )selfr:   r;   rz   r   rb   r   r   r   r9   r~   rC   r{   r   r   r   s                   r<   __init__LogisticRegression.__init__  sT    & 	*!2(( &$ r>   prefer_skip_nested_validationc                   ^ ^^^^^^^^^^ [        T R                  T R                  T R                  5      mT R                  S:w  a<  T R                  b/  [
        R                  " SR                  T R                  5      5        T R                  S:X  a  T R                  c  [        S5      eT R                  c9  T R                  S:w  a  [
        R                  " S5        [        R                  mSmOT R                  mT R                  mTS:X  a  [        R                  nO [        R                  [        R                  /n[        T TTS	US
TS;  S9u  mm[        T5        [        R                   " T5      T l        T R$                  mT R$                  S:X  a5  ['        T R"                  5      S:X  a  [
        R                  " S[(        5        OZT R$                  S;   a  [
        R                  " S[(        5        O.T R$                  S:X  a  [
        R                  " S[(        5        OSm[+        TT['        T R"                  5      5      mTS:X  Ga  ['        T R"                  5      S:  a  [
        R                  " S[(        5        [-        T R.                  5      S:w  a8  [
        R                  " SR                  [-        T R.                  5      5      5        [1        TTT R                  T R2                  T R4                  T R6                  T R                  T R                  T R8                  T R:                  T R<                  T R>                  TS9u  T l         T l!        T l"        T $ TS;   a  [G        TSS9RI                  5       mOSm['        T R"                  5      nT R"                  nUS:  a  [        SUS   -  5      e['        T R"                  5      S:X  a  SnUSS nT RJ                  (       a  [M        T SS5      nOSnUbF  T R2                  (       a5  [        RN                  " UT RB                  SS2[        RP                  4   SS 9nTS:X  a  S/nU/nUc  S/U-  n[S        [T        5      mTS;   a  S!nOS"nTS#;   a+  ['        U5      S:X  a  [-        T R.                  5      S:X  a  SmOSm[W        T R.                  T R8                  US$9" UUUUUUUUU UU4S% j[Y        Xg5       5       5      n	[Y        U	6 u  pn[        RZ                  " U[        R\                  S&9SS2S4   T l"        TR^                  S   nTS:X  a  U	S   S   T l         OQ[        RZ                  " U	5      T l         T R@                  Ra                  X\[c        T R2                  5      -   5      T l         T R2                  (       a4  T R@                  SS2S'4   T l!        T R@                  SS2SS'24   T l         T $ [        Rd                  " U5      T l!        T $ )(a  
Fit the model according to the given training data.

Parameters
----------
X : {array-like, sparse matrix} of shape (n_samples, n_features)
    Training vector, where `n_samples` is the number of samples and
    `n_features` is the number of features.

y : array-like of shape (n_samples,)
    Target vector relative to X.

sample_weight : array-like of shape (n_samples,) default=None
    Array of weights that are assigned to individual samples.
    If not provided, then each sample is given unit weight.

    .. versionadded:: 0.17
       *sample_weight* support to LogisticRegression.

Returns
-------
self
    Fitted estimator.

Notes
-----
The SAGA solver supports both float64 and float32 bit arrays.
r5   NzNl1_ratio parameter is only used when penalty is 'elasticnet'. Got (penalty={})z6l1_ratio must be specified when penalty is elasticnet.rf   z>Setting penalty=None will ignore the C and l1_ratio parametersr4   rZ   rI   r   rJ   rL   rM   r_   rN   rB   r   'multi_class' was deprecated in version 1.5 and will be removed in 1.8. From then on, binary problems will be fit as proper binary  logistic regression models (as if multi_class='ovr' were set). Leave it to its default value to avoid this warning.rB   r@   'multi_class' was deprecated in version 1.5 and will be removed in 1.8. From then on, it will always use 'multinomial'. Leave it to its default value to avoid this warning.rA   z'multi_class' was deprecated in version 1.5 and will be removed in 1.8. Use OneVsRestClassifier(LogisticRegression(..)) instead. Leave it to its default value to avoid this warning.r@   r2   r   r*   z]'n_jobs' > 1 does not have any effect when 'solver' is set to 'liblinear'. Got 'n_jobs' = {}.r   r   TsquaredeThis solver needs samples of at least 2 classes in the data, but the data contains only one class: %rr   r   rd   threads	processesr`   r   r{   preferc              3   ,  >#    U  H  u  pT" TT40 S U_ST/_STR                   _STR                  _STR                  _STR                  _ST_ST_STR                  _S	TR
                  _S
S_STR                  _SU_ST	_ST_ST
_ST_6v   M     g7f)r   r   r   rb   rz   r{   r9   rC   r~   r   r   Fr   rc   r:   r   rT   r   N)r   rb   rz   r{   r~   r   r   ).0class_warm_start_coef_C_r   r   rC   r   	path_funcr:   rT   r   r9   rS   s      r<   	<genexpr>)LogisticRegression.fit.<locals>.<genexpr>h  s      X
, -K(+  ! 4	
  #00 HH   (  ".. " ".. &   !" !0#$ ,%& $'* -Ks   BBrU   rV   )3r=   r9   r:   r;   r   r   r   formatr8   r   r   infr   float32r)   r!   r   r   rC   r   r   rE   r   r   r   rb   r   r   r{   r~   rz   r   r   r   n_iter_r   r   r   getattrr   r   r%   r   r$   zipasarrayr   r   r   r   r   )r   r   rS   rT   _dtyperD   r   warm_start_coefr  fold_coefs__r  r   r  r   rC   r   r  r:   r9   s   ````         @@@@@@@r<   fitLogisticRegression.fit  s   < t{{DLL$))D<<<'DMM,EMM%vdll3 <<<'DMM,AUVV<<vv}T BGBllGWZZFjj"**-F &.J J
1 	%Q'		! &&},T]]1Cq1HMML
  !88MML  &MML  !K(fc$-->PQ[ 4==!A%
 "  ,1#V$4T[[$AB
 9G""&&!!		!!+95DJ K_$'48<<>O"O&	==q='{+  t}}"I|H??%dGT:O"O&4+=+= iiBJJ!?aO
 -'vH./O"#fy0O56	 _$F F ??H" -2 IIdkk4<<PVW X
 X
, -0,J-X
 
2 #&{"3zz':1a4@WWQZ
-'$Q*DJK0DJ++D,>,>(??DJ "jjB/DOAssF+DJ  !hhy1DOr>   c                   > [        U 5        U R                  S;   =(       dE    U R                  S;   =(       a/    U R                  R                  S:*  =(       d    U R                  S:H  nU(       a  [
        TU ]  U5      $ U R                  U5      nUR                  S:X  a  [        R                  U* U4   nOUn[        USS9$ )a3  
Probability estimates.

The returned estimates for all classes are ordered by the
label of classes.

For a multi_class problem, if multi_class is set to be "multinomial"
the softmax function is used to find the predicted probability of
each class.
Else use a one-vs-rest approach, i.e. calculate the probability
of each class assuming it to be positive using the logistic function
and normalize these values across all the classes.

Parameters
----------
X : array-like of shape (n_samples, n_features)
    Vector to be scored, where `n_samples` is the number of samples and
    `n_features` is the number of features.

Returns
-------
T : array-like of shape (n_samples, n_classes)
    Returns the probability of the sample for each class in the model,
    where classes are ordered as they are in ``self.classes_``.
)rA   r   )r@   r   r   r2   r*   Fr]   )r(   rC   r   r   r9   super_predict_proba_lrdecision_functionndimr   c_r   )r   r   rA   decisiondecision_2d	__class__s        r<   predict_proba LogisticRegression.predict_proba  s    4 	/1 
 66 H##q(FDKK;,F 	 7,Q//--a0H}}! !eeXIx$78&;U33r>   c                 L    [         R                  " U R                  U5      5      $ )a   
Predict logarithm of probability estimates.

The returned estimates for all classes are ordered by the
label of classes.

Parameters
----------
X : array-like of shape (n_samples, n_features)
    Vector to be scored, where `n_samples` is the number of samples and
    `n_features` is the number of features.

Returns
-------
T : array-like of shape (n_samples, n_classes)
    Returns the log-probability of the sample for each class in the
    model, where classes are ordered as they are in ``self.classes_``.
)r   r   r+  )r   r   s     r<   predict_log_proba$LogisticRegression.predict_log_proba  s    & vvd((+,,r>   c                 F   > [         TU ]  5       nSUR                  l        U$ NTr#  __sklearn_tags__
input_tagssparser   tagsr*  s     r<   r3  #LogisticRegression.__sklearn_tags__  !    w')!%r>   )r   r   r   r   r;   rb   r   r   r   r~   rC   r  r   r:   r   r9   rz   r{   r   )r4   r   )__name__
__module____qualname____firstlineno____doc__r   r   r   r   r   r   r   __annotations__r   r   r   r+  r.  r3  __static_attributes____classcell__r*  s   @r<   r   r   =  sO   hV	 9:DAq$v67tQW56#&tQYGHz:,7>'(U

 h4?@; k"dAq8$?56:|n-.
'$D 6 !! 
 #!!F 5n 6n`*4X-* r>   r   c                   l  ^  \ rS rSr% Sr0 \R                  Er\\S'   S H  r	\R                  \	5        M     \R                  \" \SSSS9S	/S
/\" \" \" 5       5      5      \S/S	S/S/\" 1 Sk5      /S.5        SSSSSSSSSSSSSSSSSS.S jr\" SS9S!S j5       rS!S jrS rS rU 4S jrS rU =r$ )"LogisticRegressionCVi  aJ2  Logistic Regression CV (aka logit, MaxEnt) classifier.

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

This class implements logistic regression using liblinear, newton-cg, sag
or lbfgs optimizer. The newton-cg, sag and lbfgs solvers support only L2
regularization with primal formulation. The liblinear solver supports both
L1 and L2 regularization, with a dual formulation only for the L2 penalty.
Elastic-Net penalty is only supported by the saga solver.

For the grid of `Cs` values and `l1_ratios` values, the best hyperparameter
is selected by the cross-validator
:class:`~sklearn.model_selection.StratifiedKFold`, but it can be changed
using the :term:`cv` parameter. The 'newton-cg', 'sag', 'saga' and 'lbfgs'
solvers can warm-start the coefficients (see :term:`Glossary<warm_start>`).

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

Parameters
----------
Cs : int or list of floats, default=10
    Each of the values in Cs describes the inverse of regularization
    strength. If Cs is as an int, then a grid of Cs values are chosen
    in a logarithmic scale between 1e-4 and 1e4.
    Like in support vector machines, smaller values specify stronger
    regularization.

fit_intercept : bool, default=True
    Specifies if a constant (a.k.a. bias or intercept) should be
    added to the decision function.

cv : int or cross-validation generator, default=None
    The default cross-validation generator used is Stratified K-Folds.
    If an integer is provided, then it is the number of folds used.
    See the module :mod:`sklearn.model_selection` module for the
    list of possible cross-validation objects.

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

dual : bool, default=False
    Dual (constrained) or primal (regularized, see also
    :ref:`this equation <regularized-logistic-loss>`) formulation. Dual formulation
    is only implemented for l2 penalty with liblinear solver. Prefer dual=False when
    n_samples > n_features.

penalty : {'l1', 'l2', 'elasticnet'}, default='l2'
    Specify the norm of the penalty:

    - `'l2'`: add a L2 penalty term (used by default);
    - `'l1'`: add a L1 penalty term;
    - `'elasticnet'`: both L1 and L2 penalty terms are added.

    .. warning::
       Some penalties may not work with some solvers. See the parameter
       `solver` below, to know the compatibility between the penalty and
       solver.

scoring : str or callable, default=None
    The scoring method to use for cross-validation. Options:

    - str: see :ref:`scoring_string_names` for options.
    - callable: a scorer callable object (e.g., function) with signature
      ``scorer(estimator, X, y)``. See :ref:`scoring_callable` for details.
    - `None`: :ref:`accuracy <accuracy_score>` is used.

solver : {'lbfgs', 'liblinear', 'newton-cg', 'newton-cholesky', 'sag', 'saga'},             default='lbfgs'

    Algorithm to use in the optimization problem. Default is 'lbfgs'.
    To choose a solver, you might want to consider the following aspects:

    - For small datasets, 'liblinear' is a good choice, whereas 'sag'
      and 'saga' are faster for large ones;
    - For multiclass problems, all solvers except 'liblinear' minimize the full
      multinomial loss;
    - 'liblinear' might be slower in :class:`LogisticRegressionCV`
      because it does not handle warm-starting.
    - 'liblinear' can only handle binary classification by default. To apply a
      one-versus-rest scheme for the multiclass setting one can wrap it with the
      :class:`~sklearn.multiclass.OneVsRestClassifier`.
    - 'newton-cholesky' is a good choice for
      `n_samples` >> `n_features * n_classes`, especially with one-hot encoded
      categorical features with rare categories. Be aware that the memory usage
      of this solver has a quadratic dependency on `n_features * n_classes`
      because it explicitly computes the full Hessian matrix.

    .. warning::
       The choice of the algorithm depends on the penalty chosen and on
       (multinomial) multiclass support:

       ================= ============================== ======================
       solver            penalty                        multinomial multiclass
       ================= ============================== ======================
       'lbfgs'           'l2'                           yes
       'liblinear'       'l1', 'l2'                     no
       'newton-cg'       'l2'                           yes
       'newton-cholesky' 'l2',                          yes
       'sag'             'l2',                          yes
       'saga'            'elasticnet', 'l1', 'l2'       yes
       ================= ============================== ======================

    .. note::
       'sag' and 'saga' fast convergence is only guaranteed on features
       with approximately the same scale. You can preprocess the data with
       a scaler from :mod:`sklearn.preprocessing`.

    .. versionadded:: 0.17
       Stochastic Average Gradient (SAG) descent solver. Multinomial support in
       version 0.18.
    .. versionadded:: 0.19
       SAGA solver.
    .. versionadded:: 1.2
       newton-cholesky solver. Multinomial support in version 1.6.

tol : float, default=1e-4
    Tolerance for stopping criteria.

max_iter : int, default=100
    Maximum number of iterations of the optimization algorithm.

class_weight : dict or 'balanced', default=None
    Weights associated with classes in the form ``{class_label: weight}``.
    If not given, all classes are supposed to have weight one.

    The "balanced" mode uses the values of y to automatically adjust
    weights inversely proportional to class frequencies in the input data
    as ``n_samples / (n_classes * np.bincount(y))``.

    Note that these weights will be multiplied with sample_weight (passed
    through the fit method) if sample_weight is specified.

    .. versionadded:: 0.17
       class_weight == 'balanced'

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

verbose : int, default=0
    For the 'liblinear', 'sag' and 'lbfgs' solvers set verbose to any
    positive number for verbosity.

refit : bool, default=True
    If set to True, the scores are averaged across all folds, and the
    coefs and the C that corresponds to the best score is taken, and a
    final refit is done using these parameters.
    Otherwise the coefs, intercepts and C that correspond to the
    best scores across folds are averaged.

intercept_scaling : float, default=1
    Useful only when the solver `liblinear` is used
    and `self.fit_intercept` is set to `True`. In this case, `x` becomes
    `[x, self.intercept_scaling]`,
    i.e. a "synthetic" feature with constant value equal to
    `intercept_scaling` is appended to the instance vector.
    The intercept becomes
    ``intercept_scaling * synthetic_feature_weight``.

    .. note::
        The synthetic feature weight is subject to L1 or L2
        regularization as all other features.
        To lessen the effect of regularization on synthetic feature weight
        (and therefore on the intercept) `intercept_scaling` has to be increased.

multi_class : {'auto, 'ovr', 'multinomial'}, default='auto'
    If the option chosen is 'ovr', then a binary problem is fit for each
    label. For 'multinomial' the loss minimised is the multinomial loss fit
    across the entire probability distribution, *even when the data is
    binary*. 'multinomial' is unavailable when solver='liblinear'.
    'auto' selects 'ovr' if the data is binary, or if solver='liblinear',
    and otherwise selects 'multinomial'.

    .. versionadded:: 0.18
       Stochastic Average Gradient descent solver for 'multinomial' case.
    .. versionchanged:: 0.22
        Default changed from 'ovr' to 'auto' in 0.22.
    .. deprecated:: 1.5
       ``multi_class`` was deprecated in version 1.5 and will be removed in 1.8.
       From then on, the recommended 'multinomial' will always be used for
       `n_classes >= 3`.
       Solvers that do not support 'multinomial' will raise an error.
       Use `sklearn.multiclass.OneVsRestClassifier(LogisticRegressionCV())` if you
       still want to use OvR.

random_state : int, RandomState instance, default=None
    Used when `solver='sag'`, 'saga' or 'liblinear' to shuffle the data.
    Note that this only applies to the solver and not the cross-validation
    generator. See :term:`Glossary <random_state>` for details.

l1_ratios : list of float, default=None
    The list of Elastic-Net mixing parameter, with ``0 <= l1_ratio <= 1``.
    Only used if ``penalty='elasticnet'``. A value of 0 is equivalent to
    using ``penalty='l2'``, while 1 is equivalent to using
    ``penalty='l1'``. For ``0 < l1_ratio <1``, the penalty is a combination
    of L1 and L2.

Attributes
----------
classes_ : ndarray of shape (n_classes, )
    A list of class labels known to the classifier.

coef_ : ndarray of shape (1, n_features) or (n_classes, n_features)
    Coefficient of the features in the decision function.

    `coef_` is of shape (1, n_features) when the given problem
    is binary.

intercept_ : ndarray of shape (1,) or (n_classes,)
    Intercept (a.k.a. bias) added to the decision function.

    If `fit_intercept` is set to False, the intercept is set to zero.
    `intercept_` is of shape(1,) when the problem is binary.

Cs_ : ndarray of shape (n_cs)
    Array of C i.e. inverse of regularization parameter values used
    for cross-validation.

l1_ratios_ : ndarray of shape (n_l1_ratios)
    Array of l1_ratios used for cross-validation. If no l1_ratio is used
    (i.e. penalty is not 'elasticnet'), this is set to ``[None]``

coefs_paths_ : ndarray of shape (n_folds, n_cs, n_features) or                    (n_folds, n_cs, n_features + 1)
    dict with classes as the keys, and the path of coefficients obtained
    during cross-validating across each fold and then across each Cs
    after doing an OvR for the corresponding class as values.
    If the 'multi_class' option is set to 'multinomial', then
    the coefs_paths are the coefficients corresponding to each class.
    Each dict value has shape ``(n_folds, n_cs, n_features)`` or
    ``(n_folds, n_cs, n_features + 1)`` depending on whether the
    intercept is fit or not. If ``penalty='elasticnet'``, the shape is
    ``(n_folds, n_cs, n_l1_ratios_, n_features)`` or
    ``(n_folds, n_cs, n_l1_ratios_, n_features + 1)``.

scores_ : dict
    dict with classes as the keys, and the values as the
    grid of scores obtained during cross-validating each fold, after doing
    an OvR for the corresponding class. If the 'multi_class' option
    given is 'multinomial' then the same scores are repeated across
    all classes, since this is the multinomial class. Each dict value
    has shape ``(n_folds, n_cs)`` or ``(n_folds, n_cs, n_l1_ratios)`` if
    ``penalty='elasticnet'``.

C_ : ndarray of shape (n_classes,) or (n_classes - 1,)
    Array of C that maps to the best scores across every class. If refit is
    set to False, then for each class, the best C is the average of the
    C's that correspond to the best scores for each fold.
    `C_` is of shape(n_classes,) when the problem is binary.

l1_ratio_ : ndarray of shape (n_classes,) or (n_classes - 1,)
    Array of l1_ratio that maps to the best scores across every class. If
    refit is set to False, then for each class, the best l1_ratio is the
    average of the l1_ratio's that correspond to the best scores for each
    fold.  `l1_ratio_` is of shape(n_classes,) when the problem is binary.

n_iter_ : ndarray of shape (n_classes, n_folds, n_cs) or (1, n_folds, n_cs)
    Actual number of iterations for all classes, folds and Cs.
    In the binary or multinomial cases, the first dimension is equal to 1.
    If ``penalty='elasticnet'``, the shape is ``(n_classes, n_folds,
    n_cs, n_l1_ratios)`` or ``(1, n_folds, n_cs, n_l1_ratios)``.

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
--------
LogisticRegression : Logistic regression without tuning the
    hyperparameter `C`.

Examples
--------
>>> from sklearn.datasets import load_iris
>>> from sklearn.linear_model import LogisticRegressionCV
>>> X, y = load_iris(return_X_y=True)
>>> clf = LogisticRegressionCV(cv=5, random_state=0).fit(X, y)
>>> clf.predict(X[:2, :])
array([0, 0])
>>> clf.predict_proba(X[:2, :]).shape
(2, 3)
>>> clf.score(X, y)
0.98...
r   )r   r   r   r*   Nr   r   z
array-like	cv_objectr   >   r   r4   r5   )r   cvr   	l1_ratiosrefitr:   
   TFr4   rZ   r   rh   r   rf   r   )r   rb   rF  r;   r:   r   r9   rz   r~   r   r   r{   rH  r   rC   r   rG  c                    Xl         X l        X0l        X@l        XPl        X`l        Xl        Xl        Xl        Xl	        Xl
        Xpl        Xl        Xl        Xl        UU l        UU l        g r   )r   rb   rF  r;   r:   r   rz   r~   r   r   r{   r9   rH  r   rC   r   rG  )r   r   rb   rF  r;   r:   r   r9   rz   r~   r   r   r{   rH  r   rC   r   rG  s                     r<   r   LogisticRegressionCV.__init__  sb    * *	 (
!2&("r>   r   c                   ^ ^^^^$^%^&^'^(^)^*^+ [        UT S5        [        T R                  T R                  T R                  5      m+T R                  S:X  al  T R
                  b:  [        T R
                  5      S:X  d!  [        S T R
                   5       5      (       a  [        ST R
                  -  5      eT R
                  m&O?T R
                  b/  [        R                  " SR                  T R                  5      5        S/m&[        T TTS[        R                  S	T+S
;  S9u  mm[        T5        T R                   m$[#        5       R%                  T5      nUR'                  T5      m[)        T$[*        5      (       a9  T$R-                  5        VVs0 s H  u  pgUR'                  U/5      S   U_M     snnm$UR.                  =nT l        UR'                  UR.                  5      n	T R0                  m(T R0                  S:X  a5  [        T R.                  5      S:X  a  [        R                  " S[2        5        OZT R0                  S;   a  [        R                  " S[2        5        O.T R0                  S:X  a  [        R                  " S[2        5        OSm([5        T(T+[        U5      5      m(T+S;   a  [7        TSS9R9                  5       m'OSm'[;        5       (       a  [=        T S4ST0UD6m*OB[?        5       m*[?        0 S9T*l         [?        US9T*l!        Tb  TT*RB                  RD                  S'   [G        T RH                  TSS9n
[K        U
RL                  " TT40 T*R@                  RL                  D65      m%[        U	5      nUS:  a  [        SUS   -  5      eUS:X  a  SnU	SS n	USS nT(S:X  a  S/=pOU	nUnT$S:X  aG  [O        T$[        RP                  " [        T R.                  5      5      TTS9m$[+        [S        T$5      5      m$[U        [V        5      m)T R                  S;   a  SnOS n[Y        T RZ                  T R\                  US!9" UU$U%U&U'U(U)U*UU U+U4S" jU 5       5      n[_        U6 u  nnnnUS   T l0        T(S:X  a  [        Rb                  " U[        T%5      [        T&5      [        T R`                  5      -  US#45      n[        Rd                  " USS5      n[        Rd                  " USS5      n[        Rb                  " US[        T%5      [        T R`                  5      [        T&5      -  45      T l3        [        Rh                  " UUSS45      nO[        Rb                  " UU[        T%5      [        T R`                  5      [        T&5      -  S#45      n[        Rb                  " UU[        T%5      [        T R`                  5      [        T&5      -  45      T l3        [        Rb                  " UU[        T%5      S#45      n[+        [_        UU5      5      T l5        [+        [_        UU5      5      T l6        [K        5       T l7        [K        5       T l8        [        Rr                  " UTRt                  S   45      T l;        [        Rx                  " U5      T l=        [S        [_        X5      5       GH  u  nu  nnT(S:X  a  T Rj                  U   nT Rl                  U   nOUS   nT R|                  (       Gao  UR                  SS$9R                  5       nU[        T R`                  5      -  nT R`                  U   nT Rn                  R                  U5        U[        T R`                  5      -  nT&U   nT Rp                  R                  U5        T(S:X  a#  [        R                  " USS2SS2USS24   SS$9nO[        R                  " USS2USS24   SS$9n[        TT40 S%U_S&U/_S'T+_S(T R                  _S)U_S*T R                  _S+T R                  _S,T R                  _S-T$_S.T(_S/[9        ST R\                  S-
  5      _S0T R                  _S1S2_S3T'_ST_S4U_6u  n  nUS   nGOo[        R                  " USS$9nT(S:X  aD  [        R                  " [        [        T%5      5       Vs/ s H  nUUUU   SS24   PM     snSS$9nOF[        R                  " [        [        T%5      5       Vs/ s H  nUSS2UUU   SS24   PM     snSS$9nU[        T R`                  5      -  n T Rn                  R                  [        R                  " T R`                  U    5      5        T R                  S:X  aK  U[        T R`                  5      -  n!T Rp                  R                  [        R                  " T&U!   5      5        OT Rp                  R                  S5        T(S:X  a  [        Rh                  " T Rn                  U5      T l7        [        Rh                  " T Rp                  U5      T l8        USS2STRt                  S   24   T l;        T R                  (       a  USS2S#4   T l=        GM  GM  USTRt                  S    T Rv                  U'   T R                  (       d  GM  US#   T Rz                  U'   GM      [        R                  " T Rn                  5      T l7        [        R                  " T Rp                  5      T l8        [        R                  " T&5      T lJ        T R
                  Gb  T Rl                  R-                  5        H  u  nn"U"Rc                  [        T%5      T R                  R                  T R`                  R                  S#45      T Rl                  U'   [        R                  " T Rl                  U   S55      T Rl                  U'   M     T Rj                  R-                  5        H  u  nn#U#Rc                  [        T%5      T R                  R                  T R`                  R                  45      T Rj                  U'   [        R                  " T Rj                  U   S65      T Rj                  U'   M     T Rf                  Rc                  S#[        T%5      T R                  R                  T R`                  R                  45      T l3        [        R                  " T Rf                  S75      T l3        T $ s  snnf s  snf s  snf )8a  Fit the model according to the given training data.

Parameters
----------
X : {array-like, sparse matrix} of shape (n_samples, n_features)
    Training vector, where `n_samples` is the number of samples and
    `n_features` is the number of features.

y : array-like of shape (n_samples,)
    Target vector relative to X.

sample_weight : array-like of shape (n_samples,) default=None
    Array of weights that are assigned to individual samples.
    If not provided, then each sample is given unit weight.

**params : dict
    Parameters to pass to the underlying splitter and scorer.

    .. versionadded:: 1.4

Returns
-------
self : object
    Fitted LogisticRegressionCV estimator.
r   r5   Nr   c              3      #    U  H<  n[        U[        R                  5      (       + =(       d    US :  =(       d    US:  v   M>     g7f)r   r*   N)r   r   Number)r  r   s     r<   r  +LogisticRegressionCV.fit.<locals>.<genexpr>]  sF       %3	 'x@@ (#a<(#a<( %3s   AAzGl1_ratios must be a list of numbers between 0 and 1; got (l1_ratios=%r)zOl1_ratios parameter is only used when penalty is 'elasticnet'. Got (penalty={})rI   r   rJ   r  rB   r   r  r  r  rA   z'multi_class' was deprecated in version 1.5 and will be removed in 1.8. Use OneVsRestClassifier(LogisticRegressionCV(..)) instead. Leave it to its default value to avoid this warning.r@   r   Tr  rT   )splitr   )
classifierr  r*   rY   rQ   r	  r
  r  c           	   3     >#    U  H  nT  H  u  p#T  H  nT" TTUU40 S U_STR                   _STR                  _STR                  _STR                  _ST_STR                  _STR
                  _STR                  _S	T_S
TR                  _ST
_STR                  _STR                  _ST	_ST_SU_STR                  R                  _6v   M     M     M     g7f)r   r   rb   r:   r;   r9   rz   r~   r{   r   r   rC   r   r   r   rT   r   r   N)r   rb   r:   r;   rz   r~   r{   r   r   r   scorerr   )r  labelr   r   r   r   r   folds
l1_ratios_r   rC   r  routed_paramsrT   r   r9   rS   s        r<   r  rO    s<     X
2 -$&5 	
   77 #00  YY  HH   *   (!" #'"8"8#$ "..%& !0'( ,)* "+, +1177-4 '52  %30 -s   CCrV   rd   r   r   r9   rb   rc   r~   rz   r:   r   rC   r{   r   r   Fr   r   )r   r   r*   rj   )r   r   r*   )r   r*   rj   r   )Mr   r=   r9   r:   r;   rG  r   anyr8   r   r   r  r)   r   r   r!   r   r   r   	transformr   r   itemsr   rC   r   rE   r   r   r   r    r   splitterrT  r   r   rF  r   rP  r   aranger   r%   r   r$   r   r{   r  Cs_r   swapaxesr  tilescores_coefs_paths_r  	l1_ratio_emptyr   r   r   r   rH  r   argmaxr   meanr   rb   r~   rz   r   ranger  rW  r   	transpose),r   r   rS   rT   r   label_encoderclsvrR   encoded_labelsrF  rD   iter_encoded_labelsiter_classesr  r  coefs_pathsr   r   r  indexencoded_label
best_indexbest_index_Cr  best_index_l1rc  	coef_initr   r  best_indicesr   best_indices_Cbest_indices_l1
coefs_pathr   r   rV  rW  r   rC   r  rX  r9   s,   ````                                @@@@@@@@r<   r   LogisticRegressionCV.fit:  sl   6 	&$.t{{DLL$))D<<<'&t~~&!+  %)NN   !248NNC  J~~)88>t||8L
 J** &.J J
1 	%Q'(( %**1-##A&lD))COCUCUCWCW''.q114CWL
 #0"8"88$-&001G1GH &&},T]]1Cq1HMML
  !88MML  &MML  !K(fc'lK_$'48<<>O"O+ , 	M "GM%*_M"#(v#6M (>K$$**?; dggqT2RXXaCm&<&<&B&BCD '	q=&qz*  > I+AB/NabkG -'267,"0"L :%/		#dmm"45+	L  	, 78L12	 ;;/)F Fdkk4<<PVW X
 X
2 -3X
 
R ,/+<(Ra5-'**US_s488}<iLK ++k1a8K++k1a8K::!SZTXXZ)HIDL WWViA%67F**CJDHHJ(GLK ::)SZTXXZ1PQDL FYE
B$?@C01 Wk!:;&XXy!''!*56
((9-+42,
'E'C e#c*"//4   zzz $ZZQZ/668
)CM9XXl+r" *c$((m ;&}5	%%i0-/ "Aq*a4G(Hq QI "Az14D(EA NI 4 , t	
 " #'"4"4 # "]]  !LL ". !,  4<<!#34 "&!2!2 !&  %4!" #0#$ '%1a( aD
  "yya8%'EJ3u:EVWEVQQ%:;EVWA
  &+3u:%6%6 (1l1oq(@A%6 A ".DHH!=rwwtxx'?@A<<</&2c$((m&CONN))"''*_2M*NONN))$/m+''$''95!#!Cq,AGGAJ,/
%%&'2hDO & %&l
O

5!%%%-.rUDOOE*{,
~ **TWW%DNN3**Z0 >>% $(#4#4#:#:#<Z)3););Z!5!5txx}}bI*!!#& *,%%c*L*!!#&	 $= #ll002
U$)MMZ!5!5txx}}E%S! %'LLc1BI$NS!	 3  <<//SZ!5!5txx}}EDL <<lCDLq	l X
s   "s"s(
s-
c                    [        X@S5        U R                  5       n[        5       (       a  [        U S4SU0UD6nO3[	        5       n[	        0 S9Ul        Ub  X6R
                  R                  S'   U" U UU40 UR
                  R                  D6$ )a  Score using the `scoring` option on the given test data and labels.

Parameters
----------
X : array-like of shape (n_samples, n_features)
    Test samples.

y : array-like of shape (n_samples,)
    True labels for X.

sample_weight : array-like of shape (n_samples,), default=None
    Sample weights.

**score_params : dict
    Parameters to pass to the `score` method of the underlying scorer.

    .. versionadded:: 1.4

Returns
-------
score : float
    Score of self.predict(X) w.r.t. y.
r   rT   rQ  )r   _get_scorerr   r    r   rT  r   )r   r   rS   rT   r   r   rX  s          r<   r   LogisticRegressionCV.score  s    0 	,g6""$+ , 	M "GM#(r?M (>K$$**?;
 ""((	
 	
r>   c                 :   [        U R                  R                  S9R                  U 5      R	                  U R
                  [        5       R	                  SSS9S9R	                  U R                  5       [        5       R	                  SSS9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   rP  )callercallee)r\  method_mappingr   )rT  r  )r   r*  r:  add_self_requestaddrF  r   r|  )r   routers     r<   get_metadata_routing)LogisticRegressionCV.get_metadata_routing  s      !8!89d#S,22%2P   S''),GG4E'2	   	 r>   c                 B    U R                   =(       d    Sn[        U5      $ )z`Get the scorer based on the scoring method specified.
The default scoring method is `accuracy`.
accuracy)r   r   )r   r   s     r<   r|   LogisticRegressionCV._get_scorer	  s     ,,,*'""r>   c                 F   > [         TU ]  5       nSUR                  l        U$ r1  r2  r6  s     r<   r3  %LogisticRegressionCV.__sklearn_tags__	  r9  r>   )r  r   r^  r   r   r   rb  rF  r;   rb   r   r   rc  rG  rW  r~   rC   r  r   r:   r   rH  ra  r   r9   rz   r{   r   )r:  r;  r<  r=  r>  r   r   r   r?  parampopupdater   r   r   setr   callabler   r   r   r   r  r|  r3  r@  rA  rB  s   @r<   rD  rD    s   dL	 $Q&8&O&O#PDP0""5) 1 !!Haf=|L-"3'7'9#:;XtL&-["#=>?	
	  '%#N 5B 6BH-
^># r>   rD  )NrI  Trh   r   r   rZ   NNFr4   rf   r@   NTNNNr*   )Nr>  r   r   r   r   numpyr   joblibr   scipyr   sklearn.metricsr   
_loss.lossr	   r
   baser   metricsr   model_selectionr   preprocessingr   r   	svm._baser   utilsr   r   r   r   r   utils._param_validationr   r   r   utils.extmathr   r   utils.fixesr   utils.metadata_routingr   r   r   r   r    utils.multiclassr!   utils.optimizer"   r#   utils.parallelr$   r%   utils.validationr&   r'   r(   r)   _baser+   r,   r-   _glm.glmr.   _linear_lossr/   _sagr0   r   r=   rE   r   r   r   rD   r>   r<   <module>r     s     "  #  , >    & 8 &  C B . <  < ? .  I H * )  !(* 			+q1ja/H\
. \
~{-/Dm {r>   