
    -i}                     &   S r SSKJrJr  SSKrSSK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  SSKJr  SS	KJrJrJr  SS
KJr  SSKJr  SSKJrJ r J!r!  SSK"J#r#  SSK$J%r%J&r&   " S S\\5      r' " S S\'5      r( " S S\'5      r) " S S\'5      r*g)z>
Generalized Linear Models with Exponential Dispersion Family
    )IntegralRealN   )HalfGammaLossHalfPoissonLossHalfSquaredErrorHalfTweedieLossHalfTweedieLossIdentity)BaseEstimatorRegressorMixin_fit_context)check_array)_openmp_effective_n_threads)HiddenInterval
StrOptions)"_get_additional_lbfgs_options_dict)_check_optimize_result)_check_sample_weightcheck_is_fittedvalidate_data   )LinearModelLoss   )NewtonCholeskySolverNewtonSolverc                      ^  \ rS rSr% Sr\" \SSSS9/S/\" SS	15      \" \	5      /\" \
S
SSS9/\" \SSSS9/S/S/S.r\\S'   SSSSSSSS.S jr\" SS9SS j5       rS rS rSS jrU 4S jrS rSrU =r$ )_GeneralizedLinearRegressor   a  Regression via a penalized Generalized Linear Model (GLM).

GLMs based on a reproductive Exponential Dispersion Model (EDM) aim at fitting and
predicting the mean of the target y as y_pred=h(X*w) with coefficients w.
Therefore, the fit minimizes the following objective function with L2 priors as
regularizer::

    1/(2*sum(s_i)) * sum(s_i * deviance(y_i, h(x_i*w)) + 1/2 * alpha * ||w||_2^2

with inverse link function h, s=sample_weight and per observation (unit) deviance
deviance(y_i, h(x_i*w)). Note that for an EDM, 1/2 * deviance is the negative
log-likelihood up to a constant (in w) term.
The parameter ``alpha`` corresponds to the lambda parameter in glmnet.

Instead of implementing the EDM family and a link function separately, we directly
use the loss functions `from sklearn._loss` which have the link functions included
in them for performance reasons. We pick the loss functions that implement
(1/2 times) EDM deviances.

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

.. versionadded:: 0.23

Parameters
----------
alpha : float, default=1
    Constant that multiplies the penalty term and thus determines the
    regularization strength. ``alpha = 0`` is equivalent to unpenalized
    GLMs. In this case, the design matrix `X` must have full column rank
    (no collinearities).
    Values must be in the range `[0.0, inf)`.

fit_intercept : bool, default=True
    Specifies if a constant (a.k.a. bias or intercept) should be
    added to the linear predictor (X @ coef + intercept).

solver : {'lbfgs', 'newton-cholesky'}, default='lbfgs'
    Algorithm to use in the optimization problem:

    'lbfgs'
        Calls scipy's L-BFGS-B optimizer.

    'newton-cholesky'
        Uses Newton-Raphson steps (in arbitrary precision arithmetic equivalent to
        iterated reweighted least squares) with an inner Cholesky based solver.
        This solver is a good choice for `n_samples` >> `n_features`, 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` because it explicitly computes the Hessian matrix.

        .. versionadded:: 1.2

max_iter : int, default=100
    The maximal number of iterations for the solver.
    Values must be in the range `[1, inf)`.

tol : float, default=1e-4
    Stopping criterion. For the lbfgs solver,
    the iteration will stop when ``max{|g_j|, j = 1, ..., d} <= tol``
    where ``g_j`` is the j-th component of the gradient (derivative) of
    the objective function.
    Values must be in the range `(0.0, inf)`.

warm_start : bool, default=False
    If set to ``True``, reuse the solution of the previous call to ``fit``
    as initialization for ``coef_`` and ``intercept_``.

verbose : int, default=0
    For the lbfgs solver set verbose to any positive number for verbosity.
    Values must be in the range `[0, inf)`.

Attributes
----------
coef_ : array of shape (n_features,)
    Estimated coefficients for the linear predictor (`X @ coef_ +
    intercept_`) in the GLM.

intercept_ : float
    Intercept (a.k.a. bias) added to linear predictor.

n_iter_ : int
    Actual number of iterations used in the solver.

_base_loss : BaseLoss, default=HalfSquaredError()
    This is set during fit via `self._get_loss()`.
    A `_base_loss` contains a specific loss function as well as the link
    function. The loss to be minimized specifies the distributional assumption of
    the GLM, i.e. the distribution from the EDM. Here are some examples:

    =======================  ========  ==========================
    _base_loss               Link      Target Domain
    =======================  ========  ==========================
    HalfSquaredError         identity  y any real number
    HalfPoissonLoss          log       0 <= y
    HalfGammaLoss            log       0 < y
    HalfTweedieLoss          log       dependent on tweedie power
    HalfTweedieLossIdentity  identity  dependent on tweedie power
    =======================  ========  ==========================

    The link function of the GLM, i.e. mapping from linear predictor
    `X @ coeff + intercept` to prediction `y_pred`. For instance, with a log link,
    we have `y_pred = exp(X @ coeff + intercept)`.
        Nleftclosedbooleanlbfgsnewton-choleskyr   neitherverbosealphafit_interceptsolvermax_itertol
warm_startr(   _parameter_constraints      ?Td   -C6?Fr   c                X    Xl         X l        X0l        X@l        XPl        X`l        Xpl        g Nr)   )selfr*   r+   r,   r-   r.   r/   r(   s           P/var/www/html/venv/lib/python3.13/site-packages/sklearn/linear_model/_glm/glm.py__init__$_GeneralizedLinearRegressor.__init__   s(     
* $    )prefer_skip_nested_validationc                    [        U UUSS/[        R                  [        R                  /SSS9u  pU R                  S:X  a  [        R                  nO8[        [        UR                  UR                  5      [        R                  5      n[        X$SSS9nUb
  [        X1US
9nUR                  u  pVU R                  5       U l        [        U R                  U R                  S9nUR                  R!                  U5      (       d.  [#        SU R                  R$                  R&                  < S35      eU R(                  (       a  [+        U S5      (       ap  U R                  (       aB  [        R,                  " U R.                  [        R0                  " U R2                  /5      45      nOU R.                  nUR5                  USS9nOZUR7                  XS
9nU R                  (       a:  UR                  R8                  R9                  [        R:                  " X#S95      US'   U R<                  n	[?        5       n
U R                  S:X  a  UR@                  n[B        RD                  RG                  UUSSU RH                  SU RJ                  S[        RL                  " [N        5      RP                  -  S.[S        SU RT                  S-
  5      EXX9U
4S9n[W        SXRH                  S9U l,        URZ                  nOU R                  S:X  aQ  []        UUU	U RJ                  U RH                  U
U RT                  S9nUR_                  XU5      nUR`                  U l,        O[c        U R                  [d        5      (       aL  U R	                  UUU	U RJ                  U RH                  U
S9nUR_                  XU5      nUR`                  U l,        O[#        SU R                   S35      eU R                  (       a  US   U l        US	S U l        U $ SU l        Xl        U $ )aI  Fit a Generalized Linear Model.

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

y : array-like of shape (n_samples,)
    Target values.

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

Returns
-------
self : object
    Fitted model.
csccsrTF)accept_sparsedtype	y_numericmulti_outputr%   Cr@   order	ensure_2dNr@   )	base_lossr+   :Some value(s) of y are out of the valid range of the loss .coef_)copyweightszL-BFGS-B2   @   )maxitermaxlsgtolftoliprintr   )methodjacoptionsargs)r-   r&   )coeflinear_lossl2_reg_strengthr.   r-   	n_threadsr(   )r[   r\   r]   r.   r-   r^   zInvalid solver=r    )3r   npfloat64float32r,   minmaxr@   r   r   shape	_get_loss
_base_lossr   r+   rH   in_y_true_range
ValueError	__class____name__r/   hasattrconcatenaterK   array
intercept_astypeinit_zero_coeflinkaverager*   r   loss_gradientscipyoptimizeminimizer-   r.   finfofloatepsr   r(   r   n_iter_xr   solve	iteration
issubclassr   )r6   Xysample_weight
loss_dtype	n_samples
n_featuresr\   r[   r]   r^   funcopt_ressols                 r7   fit_GeneralizedLinearRegressor.fit   s   (  %.::rzz*
 ;;'! JS!''2BJJ?J3%H$ 1TM !	..*%oo,,

 $$44Q77OO--669< , ??wtW55!!~~tzz288T__<M3N&OPzz;;z;6D--a-BD!!&0055::JJq8R **/1	 ;;'!,,Dnn--!#}} HH %!4!44	 94<<RSCST	 MIF . G" 2==DL 99D[[--&' /HH#C 99Q=1D==DL\22++' /HH#  C 99Q=1D==DLt{{m1=>>"2hDOcrDJ  "DOJr:   c           
          [        U 5        [        U U/ SQ[        R                  [        R                  /SSSS9nXR
                  -  U R                  -   $ )aS  Compute the linear_predictor = `X @ coef_ + intercept_`.

Note that we often use the term raw_prediction instead of linear predictor.

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

Returns
-------
y_pred : array of shape (n_samples,)
    Returns predicted values of linear predictor.
)r>   r=   cooTF)r?   r@   rF   allow_ndreset)r   r   r_   r`   ra   rK   rn   )r6   r   s     r7   _linear_predictor-_GeneralizedLinearRegressor._linear_predictorF  sO     	/::rzz*
 ::~//r:   c                 r    U R                  U5      nU R                  R                  R                  U5      nU$ )zPredict using GLM with feature matrix X.

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

Returns
-------
y_pred : array of shape (n_samples,)
    Returns predicted values.
)r   rf   rq   inverse)r6   r   raw_predictiony_preds       r7   predict#_GeneralizedLinearRegressor.predicta  s3     //2%%--n=r:   c                    U R                  U5      n[        X$R                  SSS9nUb  [        X1UR                  S9nU R                  nUR                  U5      (       d  [        SUR                   S35      e[        R                  " UR                  USS9US	9nU" UUUS
S9nUR                  R                  [        R                  " X#S	95      nU" U[        R                  " XR                  S   5      US
S9n	S
Xv-   X-   -  -
  $ )a  Compute D^2, the percentage of deviance explained.

D^2 is a generalization of the coefficient of determination R^2.
R^2 uses squared error and D^2 uses the deviance of this GLM, see the
:ref:`User Guide <regression_metrics>`.

D^2 is defined as
:math:`D^2 = 1-\frac{D(y_{true},y_{pred})}{D_{null}}`,
:math:`D_{null}` is the null deviance, i.e. the deviance of a model
with intercept alone, which corresponds to :math:`y_{pred} = \bar{y}`.
The mean :math:`\bar{y}` is averaged by sample_weight.
Best possible score is 1.0 and it can be negative (because the model
can be arbitrarily worse).

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

y : array-like of shape (n_samples,)
    True values of target.

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

Returns
-------
score : float
    D^2 of self.predict(X) w.r.t. y.
rC   FrD   NrG   rI   rJ   )y_truer   rM   r   )r   r   r   r^   r   )r   r   r@   r   rf   rg   rh   rj   r_   rr   constant_to_optimal_zerorq   tilerd   )
r6   r   r   r   r   rH   constantdeviancey_meandeviance_nulls
             r7   score!_GeneralizedLinearRegressor.scores  s   J //2!5!5SER$ 1QMOO	((++&&'q* 
 ::..at.L!
 )'	
 $$RZZ%IJ!776771:6'	
 H'M,DEEEr:   c                    > [         TU ]  5       nSUR                  l         U R	                  5       nUR                  S5      (       + UR                  l        U$ ! [        [        [        4 a     U$ f = f)NTg      )super__sklearn_tags__
input_tagssparsere   rg   target_tagspositive_onlyrh   AttributeError	TypeError)r6   tagsrH   ri   s      r7   r   ,_GeneralizedLinearRegressor.__sklearn_tags__  st    w')!%		 (I1:1J1J41P-PD*
 	 NI6 	 		s   5A A21A2c                     [        5       $ )zThis is only necessary because of the link and power arguments of the
TweedieRegressor.

Note that we do not need to pass sample_weight to the loss class as this is
only needed to set loss.constant_hessian on which GLMs do not rely.
)r   r6   s    r7   re   %_GeneralizedLinearRegressor._get_loss  s      !!r:   )rf   r*   rK   r+   rn   r-   rz   r,   r.   r(   r/   r5   )rj   
__module____qualname____firstlineno____doc__r   r   r   r   typer   r0   dict__annotations__r8   r   r   r   r   r   r   re   __static_attributes____classcell__ri   s   @r7   r   r      s    fX 4d6:;#!2344L
 h4?@sD;< k;$D   & 5X 6Xt06$IFV" "r:   r   c                   n   ^  \ rS rSr% Sr0 \R                  Er\\S'   SSSSSS	S
S.U 4S jjr	S r
SrU =r$ )PoissonRegressori  aY  Generalized Linear Model with a Poisson distribution.

This regressor uses the 'log' link function.

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

.. versionadded:: 0.23

Parameters
----------
alpha : float, default=1
    Constant that multiplies the L2 penalty term and determines the
    regularization strength. ``alpha = 0`` is equivalent to unpenalized
    GLMs. In this case, the design matrix `X` must have full column rank
    (no collinearities).
    Values of `alpha` must be in the range `[0.0, inf)`.

fit_intercept : bool, default=True
    Specifies if a constant (a.k.a. bias or intercept) should be
    added to the linear predictor (`X @ coef + intercept`).

solver : {'lbfgs', 'newton-cholesky'}, default='lbfgs'
    Algorithm to use in the optimization problem:

    'lbfgs'
        Calls scipy's L-BFGS-B optimizer.

    'newton-cholesky'
        Uses Newton-Raphson steps (in arbitrary precision arithmetic equivalent to
        iterated reweighted least squares) with an inner Cholesky based solver.
        This solver is a good choice for `n_samples` >> `n_features`, 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` because it explicitly computes the Hessian matrix.

        .. versionadded:: 1.2

max_iter : int, default=100
    The maximal number of iterations for the solver.
    Values must be in the range `[1, inf)`.

tol : float, default=1e-4
    Stopping criterion. For the lbfgs solver,
    the iteration will stop when ``max{|g_j|, j = 1, ..., d} <= tol``
    where ``g_j`` is the j-th component of the gradient (derivative) of
    the objective function.
    Values must be in the range `(0.0, inf)`.

warm_start : bool, default=False
    If set to ``True``, reuse the solution of the previous call to ``fit``
    as initialization for ``coef_`` and ``intercept_`` .

verbose : int, default=0
    For the lbfgs solver set verbose to any positive number for verbosity.
    Values must be in the range `[0, inf)`.

Attributes
----------
coef_ : array of shape (n_features,)
    Estimated coefficients for the linear predictor (`X @ coef_ +
    intercept_`) in the GLM.

intercept_ : float
    Intercept (a.k.a. bias) added to linear predictor.

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_ : int
    Actual number of iterations used in the solver.

See Also
--------
TweedieRegressor : Generalized Linear Model with a Tweedie distribution.

Examples
--------
>>> from sklearn import linear_model
>>> clf = linear_model.PoissonRegressor()
>>> X = [[1, 2], [2, 3], [3, 4], [4, 3]]
>>> y = [12, 17, 22, 21]
>>> clf.fit(X, y)
PoissonRegressor()
>>> clf.score(X, y)
np.float64(0.990)
>>> clf.coef_
array([0.121, 0.158])
>>> clf.intercept_
np.float64(2.088)
>>> clf.predict([[1, 1], [3, 4]])
array([10.676, 21.875])
r0   r1   Tr%   r2   r3   Fr   r)   c          
      ,   > [         TU ]  UUUUUUUS9  g Nr)   r   r8   	r6   r*   r+   r,   r-   r.   r/   r(   ri   s	           r7   r8   PoissonRegressor.__init__A  ,     	'! 	 	
r:   c                     [        5       $ r5   )r   r   s    r7   re   PoissonRegressor._get_lossV  s      r:    rj   r   r   r   r   r   r0   r   r   r8   re   r   r   r   s   @r7   r   r     sR    cJ$
%
<
<$D  
 
*! !r:   r   c                   n   ^  \ rS rSr% Sr0 \R                  Er\\S'   SSSSSS	S
S.U 4S jjr	S r
SrU =r$ )GammaRegressoriZ  a  Generalized Linear Model with a Gamma distribution.

This regressor uses the 'log' link function.

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

.. versionadded:: 0.23

Parameters
----------
alpha : float, default=1
    Constant that multiplies the L2 penalty term and determines the
    regularization strength. ``alpha = 0`` is equivalent to unpenalized
    GLMs. In this case, the design matrix `X` must have full column rank
    (no collinearities).
    Values of `alpha` must be in the range `[0.0, inf)`.

fit_intercept : bool, default=True
    Specifies if a constant (a.k.a. bias or intercept) should be
    added to the linear predictor `X @ coef_ + intercept_`.

solver : {'lbfgs', 'newton-cholesky'}, default='lbfgs'
    Algorithm to use in the optimization problem:

    'lbfgs'
        Calls scipy's L-BFGS-B optimizer.

    'newton-cholesky'
        Uses Newton-Raphson steps (in arbitrary precision arithmetic equivalent to
        iterated reweighted least squares) with an inner Cholesky based solver.
        This solver is a good choice for `n_samples` >> `n_features`, 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` because it explicitly computes the Hessian matrix.

        .. versionadded:: 1.2

max_iter : int, default=100
    The maximal number of iterations for the solver.
    Values must be in the range `[1, inf)`.

tol : float, default=1e-4
    Stopping criterion. For the lbfgs solver,
    the iteration will stop when ``max{|g_j|, j = 1, ..., d} <= tol``
    where ``g_j`` is the j-th component of the gradient (derivative) of
    the objective function.
    Values must be in the range `(0.0, inf)`.

warm_start : bool, default=False
    If set to ``True``, reuse the solution of the previous call to ``fit``
    as initialization for `coef_` and `intercept_`.

verbose : int, default=0
    For the lbfgs solver set verbose to any positive number for verbosity.
    Values must be in the range `[0, inf)`.

Attributes
----------
coef_ : array of shape (n_features,)
    Estimated coefficients for the linear predictor (`X @ coef_ +
    intercept_`) in the GLM.

intercept_ : float
    Intercept (a.k.a. bias) added to linear predictor.

n_features_in_ : int
    Number of features seen during :term:`fit`.

    .. versionadded:: 0.24

n_iter_ : int
    Actual number of iterations used in the solver.

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
--------
PoissonRegressor : Generalized Linear Model with a Poisson distribution.
TweedieRegressor : Generalized Linear Model with a Tweedie distribution.

Examples
--------
>>> from sklearn import linear_model
>>> clf = linear_model.GammaRegressor()
>>> X = [[1, 2], [2, 3], [3, 4], [4, 3]]
>>> y = [19, 26, 33, 30]
>>> clf.fit(X, y)
GammaRegressor()
>>> clf.score(X, y)
np.float64(0.773)
>>> clf.coef_
array([0.073, 0.067])
>>> clf.intercept_
np.float64(2.896)
>>> clf.predict([[1, 0], [2, 8]])
array([19.483, 35.795])
r0   r1   Tr%   r2   r3   Fr   r)   c          
      ,   > [         TU ]  UUUUUUUS9  g r   r   r   s	           r7   r8   GammaRegressor.__init__  r   r:   c                     [        5       $ r5   )r   r   s    r7   re   GammaRegressor._get_loss  s
    r:   r   r   r   s   @r7   r   r   Z  sR    dL$
%
<
<$D  
 
* r:   r   c            
          ^  \ rS rSr% Sr0 \R                  E\" \SSSS9/\	" 1 Sk5      /S.Er\
\S'   S	S
SSSSSSSS.	U 4S jjrS rSrU =r$ )TweedieRegressori  a  Generalized Linear Model with a Tweedie distribution.

This estimator can be used to model different GLMs depending on the
``power`` parameter, which determines the underlying distribution.

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

.. versionadded:: 0.23

Parameters
----------
power : float, default=0
        The power determines the underlying target distribution according
        to the following table:

        +-------+------------------------+
        | Power | Distribution           |
        +=======+========================+
        | 0     | Normal                 |
        +-------+------------------------+
        | 1     | Poisson                |
        +-------+------------------------+
        | (1,2) | Compound Poisson Gamma |
        +-------+------------------------+
        | 2     | Gamma                  |
        +-------+------------------------+
        | 3     | Inverse Gaussian       |
        +-------+------------------------+

        For ``0 < power < 1``, no distribution exists.

alpha : float, default=1
    Constant that multiplies the L2 penalty term and determines the
    regularization strength. ``alpha = 0`` is equivalent to unpenalized
    GLMs. In this case, the design matrix `X` must have full column rank
    (no collinearities).
    Values of `alpha` must be in the range `[0.0, inf)`.

fit_intercept : bool, default=True
    Specifies if a constant (a.k.a. bias or intercept) should be
    added to the linear predictor (`X @ coef + intercept`).

link : {'auto', 'identity', 'log'}, default='auto'
    The link function of the GLM, i.e. mapping from linear predictor
    `X @ coeff + intercept` to prediction `y_pred`. Option 'auto' sets
    the link depending on the chosen `power` parameter as follows:

    - 'identity' for ``power <= 0``, e.g. for the Normal distribution
    - 'log' for ``power > 0``, e.g. for Poisson, Gamma and Inverse Gaussian
      distributions

solver : {'lbfgs', 'newton-cholesky'}, default='lbfgs'
    Algorithm to use in the optimization problem:

    'lbfgs'
        Calls scipy's L-BFGS-B optimizer.

    'newton-cholesky'
        Uses Newton-Raphson steps (in arbitrary precision arithmetic equivalent to
        iterated reweighted least squares) with an inner Cholesky based solver.
        This solver is a good choice for `n_samples` >> `n_features`, 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` because it explicitly computes the Hessian matrix.

        .. versionadded:: 1.2

max_iter : int, default=100
    The maximal number of iterations for the solver.
    Values must be in the range `[1, inf)`.

tol : float, default=1e-4
    Stopping criterion. For the lbfgs solver,
    the iteration will stop when ``max{|g_j|, j = 1, ..., d} <= tol``
    where ``g_j`` is the j-th component of the gradient (derivative) of
    the objective function.
    Values must be in the range `(0.0, inf)`.

warm_start : bool, default=False
    If set to ``True``, reuse the solution of the previous call to ``fit``
    as initialization for ``coef_`` and ``intercept_`` .

verbose : int, default=0
    For the lbfgs solver set verbose to any positive number for verbosity.
    Values must be in the range `[0, inf)`.

Attributes
----------
coef_ : array of shape (n_features,)
    Estimated coefficients for the linear predictor (`X @ coef_ +
    intercept_`) in the GLM.

intercept_ : float
    Intercept (a.k.a. bias) added to linear predictor.

n_iter_ : int
    Actual number of iterations used in the solver.

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
--------
PoissonRegressor : Generalized Linear Model with a Poisson distribution.
GammaRegressor : Generalized Linear Model with a Gamma distribution.

Examples
--------
>>> from sklearn import linear_model
>>> clf = linear_model.TweedieRegressor()
>>> X = [[1, 2], [2, 3], [3, 4], [4, 3]]
>>> y = [2, 3.5, 5, 5.5]
>>> clf.fit(X, y)
TweedieRegressor()
>>> clf.score(X, y)
np.float64(0.839)
>>> clf.coef_
array([0.599, 0.299])
>>> clf.intercept_
np.float64(1.600)
>>> clf.predict([[1, 1], [3, 4]])
array([2.500, 4.599])
Nr'   r"   >   logautoidentity)powerrq   r0   r    r1   Tr   r%   r2   r3   Fr   )	r   r*   r+   rq   r,   r-   r.   r/   r(   c       	   
      D   > [         T
U ]  UUUUUUU	S9  X@l        Xl        g r   )r   r8   rq   r   )r6   r   r*   r+   rq   r,   r-   r.   r/   r(   ri   s             r7   r8   TweedieRegressor.__init__i  s8     	'! 	 	
 	
r:   c                    U R                   S:X  a6  U R                  S::  a  [        U R                  S9$ [        U R                  S9$ U R                   S:X  a  [        U R                  S9$ U R                   S:X  a  [        U R                  S9$ g )Nr   r   )r   r   r   )rq   r   r
   r	   r   s    r7   re   TweedieRegressor._get_loss  st    99zzQ.TZZ@@ 'TZZ8899"4499
"*<< #r:   )rq   r   )rj   r   r   r   r   r   r0   r   r   r   r   r   r8   re   r   r   r   s   @r7   r   r     sz    BH$
%
<
<$4tI>?789$D   2= =r:   r   )+r   numbersr   r   numpyr_   scipy.optimizert   
_loss.lossr   r   r   r	   r
   baser   r   r   utilsr   utils._openmp_helpersr   utils._param_validationr   r   r   utils.fixesr   utils.optimizer   utils.validationr   r   r   _linear_lossr   _newton_solverr   r   r   r   r   r   r   r:   r7   <module>r      s    #    @ ?   @ C C = 4 T T * >u".- u"p@!2 @!FA0 AHq=2 q=r:   