GitHub user actuaryzhang opened a pull request:

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

    [Minor][SparkR]Convert coefficients in summary to matrix

    ## What changes were proposed in this pull request?
    The `coefficients` component in model summary should be 'matrix' but the 
underlying structure is indeed list. This affects several models except for 
'AFTSurvivalRegressionModel' which has the correct implementation. The fix is 
to first `unlist` the coefficients returned from the `callJMethod` before 
converting to matrix. An example illustrates the issues:
    
    ```
    data(iris)
    df <- createDataFrame(iris)
    model <- spark.glm(df, Sepal_Length ~ Sepal_Width, family = "gaussian")
    s <- summary(model)
    
    > str(s$coefficients)
    List of 8
     $ : num 6.53
     $ : num -0.223
     $ : num 0.479
     $ : num 0.155
     $ : num 13.6
     $ : num -1.44
     $ : num 0
     $ : num 0.152
     - attr(*, "dim")= int [1:2] 2 4
     - attr(*, "dimnames")=List of 2
      ..$ : chr [1:2] "(Intercept)" "Sepal_Width"
      ..$ : chr [1:4] "Estimate" "Std. Error" "t value" "Pr(>|t|)"
    > s$coefficients[, 2]
    $`(Intercept)`
    [1] 0.4788963
    
    $Sepal_Width
    [1] 0.1550809
    ```
    
    This  shows that the underlying structure of coefficients is still `list`. 
    
    @felixcheung @wangmiao1981 


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

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

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

    https://github.com/apache/spark/pull/16730.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 #16730
    
----
commit c80d5301cddfe6b49fa534b60a859b609b547324
Author: actuaryzhang <actuaryzhan...@gmail.com>
Date:   2017-01-28T21:07:26Z

    convert coefficients to matrix

----


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to