Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-50673][ML] Avoid traversing model coefficients twice in `Word2…
…VecModel` constructor ### What changes were proposed in this pull request? Avoid traversing model twice in `Word2VecModel` constructor ### Why are the changes needed? In public constructor `def this(model: Map[String, Array[Float]])`, the implementation traverses the model coefficients (which is a Map) twice to build the `Word2VecModel`, for `wordIndex` and `wordVectors`, respectively. I am not sure whether it might be problematic, since the two traversals needs the same ordering. Generating the result with single pass can guarantee the correctness, anyway. ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? existing tests ### Was this patch authored or co-authored using generative AI tooling? no Closes apache#49298 from zhengruifeng/ml_w2v_build. Authored-by: Ruifeng Zheng <[email protected]> Signed-off-by: Ruifeng Zheng <[email protected]>
- Loading branch information