Github user karlhigley commented on a diff in the pull request:
https://github.com/apache/spark/pull/9843#discussion_r46051533
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/feature/IDF.scala ---
@@ -211,14 +213,17 @@ private object IDFModel {
val n = v.size
v match {
case SparseVector(size, indices, values) =>
+ val newElements = new ArrayBuffer[(Int, Double)]
val nnz = indices.size
- val newValues = new Array[Double](nnz)
var k = 0
while (k < nnz) {
- newValues(k) = values(k) * idf(indices(k))
+ val newValue = values(k) * idf(indices(k))
--- End diff --
This change doesn't affect the `idf` vector -- it's still always dense. The
existing `transform` code was producing `SparseVector`s containing explicit
zeros. This change removes the explicit zeros, but only when the input to
`transform` (not the `idf`) is a `SparseVector`.
---
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]