Github user yu-iskw commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3603#discussion_r21588804
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/feature/IDF.scala ---
    @@ -174,37 +174,18 @@ class IDFModel private[mllib] (val idf: Vector) 
extends Serializable {
        */
       def transform(dataset: RDD[Vector]): RDD[Vector] = {
         val bcIdf = dataset.context.broadcast(idf)
    -    dataset.mapPartitions { iter =>
    -      val thisIdf = bcIdf.value
    -      iter.map { v =>
    -        val n = v.size
    -        v match {
    -          case sv: SparseVector =>
    -            val nnz = sv.indices.size
    -            val newValues = new Array[Double](nnz)
    -            var k = 0
    -            while (k < nnz) {
    -              newValues(k) = sv.values(k) * thisIdf(sv.indices(k))
    -              k += 1
    -            }
    -            Vectors.sparse(n, sv.indices, newValues)
    -          case dv: DenseVector =>
    -            val newValues = new Array[Double](n)
    -            var j = 0
    -            while (j < n) {
    -              newValues(j) = dv.values(j) * thisIdf(j)
    -              j += 1
    -            }
    -            Vectors.dense(newValues)
    -          case other =>
    -            throw new UnsupportedOperationException(
    -              s"Only sparse and dense vectors are supported but got 
${other.getClass}.")
    -        }
    -      }
    -    }
    +    dataset.mapPartitions(iter => iter.map(v => 
IDFModel.transform(bcIdf.value, v)))
       }
     
       /**
    +   * Transforms tern frequency (TF) vectors to a TF-IDF vector
    --- End diff --
    
    
https://github.com/yu-iskw/spark/commit/a3bf566e923be8c8d5787d8c8ffb777a5886f360#diff-7c5eb57aa2d7d6da7afb24b85429ac14L181


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

Reply via email to