zhengruifeng commented on a change in pull request #32734:
URL: https://github.com/apache/spark/pull/32734#discussion_r646236368
##########
File path:
mllib/src/main/scala/org/apache/spark/mllib/linalg/distributed/RowMatrix.scala
##########
@@ -438,8 +443,8 @@ class RowMatrix @Since("1.0.0") (
require(m > 1, s"RowMatrix.computeCovariance called on matrix with only $m
rows." +
" Cannot compute the covariance of a RowMatrix with <= 1 row.")
val mean = Vectors.fromML(summary.mean)
-
- if (rows.first().isInstanceOf[DenseVector]) {
+ // If all the rows are sparse vectors, then compute based on
`computeSparseVectorCovariance`.
+ if (!isSparseMatrix) {
computeDenseVectorCovariance(mean, n, m)
Review comment:
@shahidki31 This is just a idea. What is your and @srowen thoughts on
it?
There are several similar existing places in ML, like `ANOVATest`.
And I am also thinking about whether to make two impls (for dense cases
using BLAS, for sparse cases using triangle-inequality) in KMeans.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]