You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Sean Owen (JIRA)" <ji...@apache.org> on 2018/01/19 15:29:01 UTC
[jira] [Resolved] (SPARK-23085) API parity for
mllib.linalg.Vectors.sparse
[ https://issues.apache.org/jira/browse/SPARK-23085?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sean Owen resolved SPARK-23085.
-------------------------------
Resolution: Fixed
Fix Version/s: 2.4.0
Issue resolved by pull request 20275
[https://github.com/apache/spark/pull/20275]
> API parity for mllib.linalg.Vectors.sparse
> -------------------------------------------
>
> Key: SPARK-23085
> URL: https://issues.apache.org/jira/browse/SPARK-23085
> Project: Spark
> Issue Type: Improvement
> Components: ML
> Affects Versions: 2.4.0
> Reporter: zhengruifeng
> Assignee: zhengruifeng
> Priority: Minor
> Fix For: 2.4.0
>
>
> Both {{ML.Vectors#sparse(size: {color:#cc7832}Int, {color}indices: Array[{color:#cc7832}Int{color}]{color:#cc7832}, {color}values: Array[{color:#cc7832}Double{color}]}} and {{ML.Vectors#sparse(size: {color:#cc7832}Int, {color}elements: {color:#4e807d}Seq{color}[({color:#cc7832}Int, Double{color})])}} support zero-length vectors.
> In old MLLib,
> {{MLLib.Vectors.sparse(size: {color:#cc7832}Int, {color}indices: Array[{color:#cc7832}Int{color}]{color:#cc7832}, {color}values: Array[{color:#cc7832}Double{color}])}} also supports it.
> However,
> {{ML.Vectors#sparse(size: {color:#cc7832}Int, {color}elements: {color:#4e807d}Seq{color}[({color:#cc7832}Int, Double{color})])}} require a positve length.
>
> {code:java}
> scala> org.apache.spark.ml.linalg.Vectors.sparse(0, Array.empty[Int], Array.empty[Double])
> res15: org.apache.spark.ml.linalg.Vector = (0,[],[])
> scala> org.apache.spark.ml.linalg.Vectors.sparse(0, Array.empty[(Int, Double)])
> res16: org.apache.spark.ml.linalg.Vector = (0,[],[])
> scala> org.apache.spark.mllib.linalg.Vectors.sparse(0, Array.empty[Int], Array.empty[Double])
> res17: org.apache.spark.mllib.linalg.Vector = (0,[],[])
> scala> org.apache.spark.mllib.linalg.Vectors.sparse(0, Array.empty[(Int, Double)])
> java.lang.IllegalArgumentException: requirement failed: The size of the requested sparse vector must be greater than 0.
> at scala.Predef$.require(Predef.scala:224)
> at org.apache.spark.mllib.linalg.Vectors$.sparse(Vectors.scala:315)
> ... 50 elided
>
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org