GitHub user actuaryzhang opened a pull request:

    https://github.com/apache/spark/pull/16344

    [SPARK-18929][ML] Add Tweedie distribution in GLM

    ## What changes were proposed in this pull request?
    I propose to add the full Tweedie family into the 
GeneralizedLinearRegression model. The Tweedie family is characterized by a 
power variance function. Currently supported distributions such as Gaussian, 
Poisson and Gamma families are a special case of the Tweedie 
https://en.wikipedia.org/wiki/Tweedie_distribution.
    
    @yanboliang @srowen @sethah 
    
    I propose to add support for the other distributions:
    - compound Poisson: 1 < variancePower < 2. This one is widely used to model 
zero-inflated continuous distributions, e.g., in insurance, finance, ecology, 
meteorology, advertising etc.
    - positive stable: variancePower > 2 and variancePower != 3. Used to model 
extreme values.
    - inverse Gaussian: variancePower = 3.
    
    The Tweedie family is supported in most statistical packages such as R 
(statmod), SAS, h2o etc.
    
    Changes made:
    - Allow `tweedie` in family. Only `identity` and `log` links are allowed 
for now. 
    - Add `variancePower` to `GeneralizedLinearRegressionBase`, which takes 
values in (1, 2) and [3, infty). Also set default value to 1.5 and add getter 
method.
    - `Family.fromName` has a second argument `variancePower`
    - Add `Tweedie` object
    - Add tests for tweedie GLM
    
    Note:
    - In computing deviance, use `math.max(y, 0.1)` to avoid taking inverse of 
0. This is the same as in R: `tweedie()$dev.res`
    - `aic` is not supported in this PR because the evaluation of the [Tweedie 
density](http://www.statsci.org/smyth/pubs/tweediepdf-series-preprint.pdf) in 
these cases are non-trivial. I will implement the density approximation method 
in a future PR.  R returns `null` (see `tweedie()$aic`).


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/actuaryzhang/spark tweedie

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/16344.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #16344
    
----
commit 952887e485fb0d5fa669b3b4c9289b8069ee7769
Author: actuaryzhang <[email protected]>
Date:   2016-12-16T00:50:51Z

    Add Tweedie family to GLM

commit 4f184ec458f5ed7d70bc5b8165481425f911d2a3
Author: actuaryzhang <[email protected]>
Date:   2016-12-19T22:50:02Z

    Fix calculation in dev resid; Add test for different var power

commit 7fe39106332663d3671b94a8ffac48ca61c48470
Author: actuaryzhang <[email protected]>
Date:   2016-12-19T23:14:37Z

    Merge test into GLR

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to