@@ -816,14 +816,14 @@ Generalized linear regression
816
816
=============================
817
817
818
818
:class: `GeneralizedLinearRegressor ` generalizes the :ref: `elastic_net ` in two
819
- ways [1 ]_. First, the predicted values :math: `\hat {y}` are linked to a linear
819
+ ways [8 ]_. First, the predicted values :math: `\hat {y}` are linked to a linear
820
820
combination of the input variables :math: `X` via an inverse link function
821
821
:math: `h` as
822
822
823
823
.. math :: \hat{y}(w, x) = h(xw) = h(w_0 + w_1 x_1 + ... + w_p x_p).
824
824
825
825
Secondly, the squared loss function is replaced by the deviance :math: `D` of an
826
- exponential dispersion model (EDM) [2 ]_. The objective function beeing minimized
826
+ exponential dispersion model (EDM) [9 ]_. The objective function beeing minimized
827
827
becomes
828
828
829
829
.. math :: \frac{1}{2s}D(y, \hat{y}) + \alpha \rho ||P_1w||_1
@@ -850,12 +850,16 @@ it is convenient to apply a link function different from the identity link
850
850
:math: `h(Xw)=\exp (Xw)`.
851
851
852
852
Note that the feature matrix `X ` should be standardized before fitting. This
853
- ensures that the penalty treats features equally.
853
+ ensures that the penalty treats features equally. The estimator can be used as
854
+ follows::
854
855
855
- >>> from sklearn import linear_model
856
- >>> reg = linear_model.GeneralizedLinearRegressor(alpha = 0.5 , l1_ratio = 0 )
857
- >>> reg = linear_model.GeneralizedLinearRegressor(alpha = 0.5 , family = ' poisson' , link = ' log' )
856
+ >>> from sklearn.linear_model import GeneralizedLinearRegressor
857
+ >>> reg = GeneralizedLinearRegressor(alpha=0.5, family='poisson', link='log')
858
858
>>> reg.fit([[0, 0], [0, 1], [2, 2]], [0, 1, 2])
859
+ GeneralizedLinearRegressor(alpha=0.5, copy_X=True, family='poisson',
860
+ fit_dispersion='chisqr', fit_intercept=True, l1_ratio=0,
861
+ link='log', max_iter=100, solver='irls', start_params=None,
862
+ tol=0.0001, verbose=0, warm_start=False)
859
863
>>> reg.coef_
860
864
array([ 0.24630255, 0.43373521])
861
865
>>> reg.intercept_
@@ -905,7 +909,7 @@ Two remarks:
905
909
906
910
* The deviances for at least Normal, Poisson and Gamma distributions are
907
911
strictly consistent scoring functions for the mean :math: `\mu `, see Eq.
908
- (19)-(20) in [3 ]_.
912
+ (19)-(20) in [10 ]_.
909
913
910
914
* If you want to model a frequency, i.e. counts per exposure (time, volume, ...)
911
915
you can do so by a Poisson distribution and passing
@@ -915,12 +919,12 @@ Two remarks:
915
919
916
920
.. topic :: References:
917
921
918
- .. [1 ] McCullagh, Peter; Nelder, John (1989). Generalized Linear Models, Second Edition. Boca Raton: Chapman and Hall/CRC. ISBN 0-412-31760-5.
922
+ .. [8 ] McCullagh, Peter; Nelder, John (1989). Generalized Linear Models, Second Edition. Boca Raton: Chapman and Hall/CRC. ISBN 0-412-31760-5.
919
923
920
- .. [2 ] Jørgensen, B. (1992). The theory of exponential dispersion models and analysis of deviance. Monografias de matemática, no. 51.
924
+ .. [9 ] Jørgensen, B. (1992). The theory of exponential dispersion models and analysis of deviance. Monografias de matemática, no. 51.
921
925
See also `Exponential dispersion model. <https://en.wikipedia.org/wiki/Exponential_dispersion_model >`_
922
926
923
- .. [3 ] Gneiting, T. (2010). `Making and Evaluating Point Forecasts. <https://arxiv.org/pdf/0912.0902.pdf >`_
927
+ .. [10 ] Gneiting, T. (2010). `Making and Evaluating Point Forecasts. <https://arxiv.org/pdf/0912.0902.pdf >`_
924
928
925
929
Stochastic Gradient Descent - SGD
926
930
=================================
0 commit comments