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

    https://github.com/apache/spark/pull/11610#discussion_r55964768
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/optim/WeightedLeastSquares.scala ---
    @@ -108,6 +101,57 @@ private[ml] class WeightedLeastSquares(
               "Consider setting fitIntercept=true.")
           }
         }
    +    /*
    +     * If more than one of the features in the data are constant (i.e. 
data matrix has constant
    +     * columns), then A^T.A is no longer positive definite and Cholesky 
decomposition fails
    +     * (because the normal equation does not have a solution).
    +     * In order to find a solution, we need to drop constant columns from 
the data matrix. Or,
    +     * we can drop corresponding column and row from A^T.A matrix.
    +     * Once we drop rows/columns from A^T.A matrix, the Cholesky 
decomposition will produce
    +     * correct coefficients. But, for the final result, we need to add 
zeros to the list of
    +     * coefficients corresponding to the constant features.
    +     */
    +    val aVarRaw = summary.aVar.values
    --- End diff --
    
    I assume that aVar will be dense here. If you would like to do it in this 
way, then `val aVarRaw = summary.aVar.toArray` to make sure it's dense. If 
`summary.aVar` is already dense, this will just return the pointer to that 
dense array without copying.


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