Github user dbtsai commented on a diff in the pull request: https://github.com/apache/spark/pull/11610#discussion_r55964451 --- 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 -- Getting values directly is very dangerous since `aVar` can be sparse or dense. Just make `val aVarRaw = summary.aVar`.
--- 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