zhengruifeng commented on pull request #32734:
URL: https://github.com/apache/spark/pull/32734#issuecomment-853607458
current estimation of data sparsity/density by
`first().isInstanceOf[DenseVector]` is too simple
`!rows.filter(_.isInstanceOf[DenseVector]` is better, but it still make
following two datasets generate differenct results:
```
val data1 = Array(
Vectors.dense(0.0, 1.0, 0.0, 7.0, 0.0 ),
Vectors.dense(2.0, 0.0, 3.0, 4.0, 5.0),
Vectors.dense(4.0, 0.0, 0.0, 6.0, 7.0)
)
val data2 = data1.map(_.toSparse)
```
if we want to do it more precisely, what about:
1, add a meta data `sparsity` or `nnz` in vector column, like existing
`numFeatures`;
2, impls can fetch this meta if any;
3, otherwise, compute average nnz, and use it to detect sparsity;
--
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]