Github user yanboliang commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11468#discussion_r54833559
  
    --- Diff: python/pyspark/ml/regression.py ---
    @@ -857,6 +858,146 @@ def predict(self, features):
             return self._call_java("predict", features)
     
     
    +@inherit_doc
    +class GeneralizedLinearRegression(JavaEstimator, HasLabelCol, 
HasFeaturesCol, HasPredictionCol,
    +                                  HasFitIntercept, HasMaxIter, HasTol, 
HasRegParam, HasWeightCol,
    +                                  HasSolver):
    +    """
    +    Generalized Linear Regression.
    +
    +    Fit a Generalized Linear Model specified by giving a symbolic 
description of the linear
    +    predictor (link function) and a description of the error distribution 
(family). It supports
    +    "gaussian", "binomial", "poisson" and "gamma" as family. Valid link 
functions for each family
    +    is listed below. The first link function of each family is the default 
one.
    +    - "gaussian" -> "identity", "log", "inverse"
    +    - "binomial" -> "logit", "probit", "cloglog"
    +    - "poisson"  -> "log", "identity", "sqrt"
    +    - "gamma"    -> "inverse", "identity", "log"
    +
    +    .. seealso:: `GLM 
<https://en.wikipedia.org/wiki/Generalized_linear_model>`_
    +
    +    >>> from pyspark.mllib.linalg import Vectors
    +    >>> df = sqlContext.createDataFrame([
    +    ...     (17.05224, Vectors.dense(3.55954, 11.19528)),
    +    ...     (13.46161, Vectors.dense(2.34561, 9.65407)),
    +    ...     (17.13384, Vectors.dense(3.37980, 12.03069)),
    +    ...     (13.84938, Vectors.dense(2.51969, 9.64902)),], ["label", 
"features"])
    +    >>> glr = GeneralizedLinearRegression()
    +    >>> model = glr.setFamily("gaussian").setLink("identity").fit(df)
    +    >>> model.transform(df).show()
    +    +--------+------------------+------------------+
    +    |   label|          features|        prediction|
    +    +--------+------------------+------------------+
    +    |17.05224|[3.55954,11.19528]|17.052776698886376|
    +    |13.46161| [2.34561,9.65407]|13.463078911930246|
    +    |17.13384| [3.3798,12.03069]| 17.13348844246882|
    +    |13.84938| [2.51969,9.64902]|13.847725946714558|
    +    +--------+------------------+------------------+
    +    ...
    +    >>> model.coefficients
    +    DenseVector([2.2263, 0.5756])
    +    >>> model.intercept
    +    2.6841196897757795
    --- End diff --
    
    The test may be unstable, it's better to use ellipsis when test double 
result such as ```2.68...```.


---
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