scala-breeze

In Apache-spark, how to add the sparse vector?

允我心安 提交于 2019-12-30 09:33:38
问题 I am trying to develop my own feedforward nerual network using spark. However I can't find the operations like multiplication , add or divide in the spark's sparse vector. The document said it is implemented using breeze vector. But I can find add operations in breeze but not in spark vector. How to solve this problem? 回答1: Spark's Vector implementations don't support algebraic operations. Unfortunately, the Spark API no longer supports to convert SparkVectors into BreezeVectors via the

Scala Breeze DenseVector Implicit failure

落花浮王杯 提交于 2019-12-25 03:24:24
问题 I've started getting this strange error; completely not sure what caused it - maybe a Maven rebuild. I can't explain this behavior... sometimes it works in IntelliJ, sometimes it doesn't, and it is failing when I run it from a jar file. This is the runtime error: java.lang.NoSuchMethodError: breeze.linalg.DenseVector$.canScaleD()Lbreeze/linalg/operators/BinaryOp and it occurs in this code: import breeze.linalg._ import breeze.linalg.DenseVector._ var planeNormal = DenseVector.zeros[Double](39

Scala (Breeze) + Intellij: “Cannot resolve symbol *”

房东的猫 提交于 2019-12-24 17:28:26
问题 I'm using Breeze to to do sum simple linear algebra operations on dense matrices. I'm using the Intellij IDEA. Here is an snippet of my code: import breeze.linalg._ val X1:DenseMatrix[Double] = DenseMatrix.zeros[Double](10, 5) + 1.0 val n1 : Double = X1.rows.toDouble val one_tall_t1 = DenseMatrix.zeros[Double](1, n1.toInt) + 1.0 val mu1=one_tall_t1*X1/n1 In the last line, the symbols * and / are shown with red color in the IDE. The error message is "Cannot resolve the symbol *". But Intellij

Why is DenseVector a mutable collection?

痴心易碎 提交于 2019-12-24 08:25:36
问题 Usually (so far always) I try to use immutable collection in Scala, especially so that if I give a reference to a collection to some other part of my program I cannot override the original source by accident. Using breeze, I would like to know: Why was it decided to have DenseVector be a mutable collection? Is this just a (maybe unwanted) side effect of using in Arrays in the background? If so, why were Arrays used, instead of another (immutable) collection? 回答1: Performance. Breeze uses

Using Breeze from Java on Spark MLlib

北慕城南 提交于 2019-12-22 09:26:19
问题 While trying to use MLlib from Java, what is the correct way to use breeze Matrix operations? For e.g. multiplication in scala it ist simply " matrix * vector ". How is the corresponding functionality expressed in Java? There are methods like " $colon$times " which might be invoked by the correct way breeze.linalg.DenseMatrix<Double> matrix= ... breeze.linalg.DenseVector<Double> vector = ... matrix.$colon$times( ... one might need an operator instance ... breeze.linalg.operators.OpMulMatrix

Matrix Operation in Spark MLlib in Java

≯℡__Kan透↙ 提交于 2019-12-21 19:47:52
问题 This question is about MLlib (Spark 1.2.1+). What is the best way to manipulate local matrices (moderate size, under 100x100, so does not need to be distributed). For instance, after computing the SVD of a dataset, I need to perform some matrix operation. The RowMatrix only provide a multiply function. The toBreeze method returns a DenseMatrix<Object> but the API does not seem Java friendly: public final <TT,B,That> That $plus(B b, UFunc.UImpl2<OpAdd$,TT,B,That> op) In Spark+Java, how to do

Scala Breeze Unable to load windows 64 dll

倖福魔咒の 提交于 2019-12-13 03:20:50
问题 Hi I'm trying to use the Breeze library for Scala but keep running into this error: [error] (run-main) java.lang.ExceptionInInitializerError: unable to load from [netlib-native_system-win-x86_64.dll] for some reasone that dll won't load when running my code. I'm using SBT, here is my build.st name := "BreezeTest" version := "1.0" scalaVersion := "2.10.3" libraryDependencies ++= Seq( "org.scalanlp" % "breeze_2.10" % "0.5.2", "org.scalanlp" % "breeze-viz_2.10" % "0.5.2" ) Has anyone else had

row-broadcasting and transposed vectors?

风格不统一 提交于 2019-12-11 12:05:21
问题 I'm trying to add a row vector to each row of a matrix: val M = DenseMatrix((1.0,2.0,3.0), (4.0,5.0,6.0)) val row = DenseVector(3.0,4.0,5.0).t val result = M(*,::) + row // error: could not find implicit value for parameter // op: OpAdd.Impl2[ // BroadcastedRows[DenseMatrix[Double],DenseVector[Double]], // Transpose[DenseVector[Double]], // That // ] I can use column vectors instead, but it seems a little convoluted: val result = (M.t(::,*) + row.t).t // result: breeze.linalg.DenseMatrix

How to build a large distributed [sparse] matrix in Apache Spark 1.0?

大憨熊 提交于 2019-12-10 18:14:38
问题 I have an RDD as such: byUserHour: org.apache.spark.rdd.RDD[(String, String, Int)] I would like to create a sparse matrix of the data for calculations like median, mean, etc. The RDD contains the row_id, column_id and value. I have two Arrays containing the row_id and column_id strings for lookup. Here is my attempt: import breeze.linalg._ val builder = new CSCMatrix.Builder[Int](rows=BCnUsers.value.toInt,cols=broadcastTimes.value.size) byUserHour.foreach{x => val row = userids.indexOf(x._1)

How to zip two DenseVectors in Scala Breeze?

最后都变了- 提交于 2019-12-10 14:58:56
问题 I'd like to zip two DenseVectors and perform an operation on each pair, and obtain a new vector as result. What is the best way to achieve this using scala-breeze? I can work around it by using their data field, but I'd need to construct a new DenseVector from the resulting array. 回答1: I should probably just make a method on DenseVector, but breeze.linalg.zipValues(dv1, dv2){(v1, v2) => ??? } should do it. 回答2: The accepted answer does not appear to work as expected. Consider this example,