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

    https://github.com/apache/spark/pull/16630#discussion_r103003591
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/r/GeneralizedLinearRegressionWrapper.scala
 ---
    @@ -99,37 +95,23 @@ private[r] object GeneralizedLinearRegressionWrapper
         val summary = glm.summary
     
         val rFeatures: Array[String] = if (glm.getFitIntercept) {
    -      Array("(Intercept)") ++ features
    +      Array("(Intercept)") ++ summary.featureNames
         } else {
    -      features
    +      summary.featureNames
         }
     
         val rCoefficients: Array[Double] = if (summary.isNormalSolver) {
    -      val rCoefficientStandardErrors = if (glm.getFitIntercept) {
    -        Array(summary.coefficientStandardErrors.last) ++
    -          summary.coefficientStandardErrors.dropRight(1)
    -      } else {
    -        summary.coefficientStandardErrors
    -      }
    +      val rCoefficientStandardErrors =
    +        summary.summaryTable.select("StdError").collect.map(_.getDouble(0))
     
    -      val rTValues = if (glm.getFitIntercept) {
    -        Array(summary.tValues.last) ++ summary.tValues.dropRight(1)
    -      } else {
    -        summary.tValues
    -      }
    +      val rTValues =
    +        summary.summaryTable.select("TValue").collect.map(_.getDouble(0))
     
    -      val rPValues = if (glm.getFitIntercept) {
    -        Array(summary.pValues.last) ++ summary.pValues.dropRight(1)
    -      } else {
    -        summary.pValues
    -      }
    +      val rPValues =
    +        summary.summaryTable.select("PValue").collect.map(_.getDouble(0))
     
    -      if (glm.getFitIntercept) {
    -        Array(glm.intercept) ++ glm.coefficients.toArray ++
    -          rCoefficientStandardErrors ++ rTValues ++ rPValues
    -      } else {
    -        glm.coefficients.toArray ++ rCoefficientStandardErrors ++ rTValues 
++ rPValues
    -      }
    +      
summary.summaryTable.select("Coefficient").collect.map(_.getDouble(0)) ++
    +        rCoefficientStandardErrors ++ rTValues ++ rPValues
    --- End diff --
    
    Yes, I checked the results, and they are the same. 


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