简体   繁体   English

斯卡拉<console> :24: 错误: 找不到微风.storage.DefaultArrayValue [Any] 类型的证据参数的隐式值

[英]Scala <console>:24: error: could not find implicit value for evidence parameter of type breeze.storage.DefaultArrayValue[Any]

I'm working with Spark and Scala(new to both).我正在使用 Spark 和 Scala(两者都是新手)。 I have this code:我有这个代码:

val indices: List[Int] = List()
val featValues: List[Double] = List()
...
val vector = SparseVector(100000, indices.toArray, featValues.toArray)

But I keep getting this error:但我不断收到此错误:

<console>:24: error: could not find implicit value for evidence parameter of type breeze.storage.DefaultArrayValue[Any]
                      val vector = SparseVector(100000, indices.toArray, featValues.toArray)

I'm sure someone only familiar with Scala could help me.我相信只有熟悉 Scala 的人可以帮助我。 The documentation for SparseVector is: SparseVector 的文档是:

http://people.apache.org/~pwendell/catalyst-docs/api/mllib/index.html#org.apache.spark.mllib.linalg.SparseVector http://people.apache.org/~pwendell/catalyst-docs/api/mllib/index.html#org.apache.spark.mllib.linalg.SparseVector

I searched Google and found this: Could not find implicit value for evidence parameter of type scala.reflect.ClassManifest[T]我搜索了谷歌,发现这个: 找不到类型 scala.reflect.ClassManifest[T] 的证据参数的隐式值

But I have no idea how to interpret the answers.但我不知道如何解释这些答案。

EDIT: I was actually importing another SparseVector from breeze while I should be importing from org.apache.spark.mllib.linalg.SparseVector.编辑:我实际上是从微风导入另一个 SparseVector,而我应该从 org.apache.spark.mllib.linalg.SparseVector 导入。

I started the interactive shell again and entered: import org.apache.spark.mllib.linalg.SparseVector我再次启动交互式shell并输入: import org.apache.spark.mllib.linalg.SparseVector

Now I'm getting error: not found: value SparseVector after repeating the same code above.现在我收到error: not found: value SparseVector重复上述相同代码后的error: not found: value SparseVector

EDIT2: I should have been clear the "..." implied that I was initializing the lists. EDIT2:我应该清楚“...”暗示我正在初始化列表。

It looks like you've not initialized indices and values, so scala at some point is trying to work with their default values.看起来您尚未初始化索引和值,因此 Scala 在某些时候会尝试使用它们的默认值。 Also based on the documentation you've linked you need to create SparseVector with new (maybe there's no companion object?)同样根据您链接的文档,您需要使用 new 创建 SparseVector (也许没有伴随对象?)

I can't test, but I suggest to try the following:我无法测试,但我建议尝试以下操作:

 val indices = Array(1,2,3) // indices is expected to be an array of Int
 val values = Array(1.0d,2.0d,3.0d) // values is an array of doubles       
 val v2 = new SparseVector(3, indices, values)

does this work?这行得通吗? If it does, the problem may be in the part of code you omitted after val featValues如果是,则问题可能出在您在val featValues之后省略的代码部分

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Scala编译错误-找不到类型为证据的隐式值 - Scala compile error - could not find implicit value for evidence parameter of type 找不到类型^的证据参数的隐含值 - could not find implicit value for evidence parameter of type ^ 无法找到类型证据参数的隐式值 - Could not find implicit value for evidence parameter of type 加特林scala扩展失败,找不到证据参数的隐式值 - Gatling scala extension fails with, could not find implicit value for evidence parameter Scala / specs2:找不到 AsExecution[ExecutionEnv =&gt; MatchResult[Future[AuthenticationResult]]] 类型的证据参数的隐式值 - Scala / specs2 : could not find implicit value for evidence parameter of type AsExecution[ExecutionEnv => MatchResult[Future[AuthenticationResult]]] 无法找到有序类型的证据参数的隐含值[T] - could not find implicit value for evidence parameter of type Ordered[T] 找不到scala.reflect.ClassManifest [T]类型的证据参数的隐式值 - Could not find implicit value for evidence parameter of type scala.reflect.ClassManifest[T] 找不到scalaz.Applicative类型的证据参数的隐含值 - could not find implicit value for evidence parameter of type scalaz.Applicative 找不到类型为证据的隐式值-Spark - could not find implicit value for evidence parameter of type - Spark 使用Scala和Breeze实现梯度下降-错误:找不到参数op的隐式值: - Implementing gradient descent with Scala and Breeze - error : could not find implicit value for parameter op:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM