-
Notifications
You must be signed in to change notification settings - Fork 28.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-19395][SparkR]Convert coefficients in summary to matrix #16730
Conversation
Test build #72113 has finished for PR 16730 at commit
|
@actuaryzhang since this changes the output, could you open a JIRA for this? |
thanks, i'd be great if you could add some tests for this - perhaps just to check the correct type and/or a subset of values |
@felixcheung I created a JIRA ticket and added in some tests. Please take a look. Thanks. |
Test build #72129 has finished for PR 16730 at commit
|
merged to master, thanks! |
## 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 Author: actuaryzhang <actuaryzhang10@gmail.com> Closes apache#16730 from actuaryzhang/sparkRCoef.
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 firstunlist
the coefficients returned from thecallJMethod
before converting to matrix. An example illustrates the issues:This shows that the underlying structure of coefficients is still
list
.@felixcheung @wangmiao1981