Questions tagged [scala-breeze]
Breeze is a linear algebra library for Scala.
186
questions
0
votes
0answers
30 views
how DenseVector to convert to DenseMatrix
I have data for N rows xM rows DenseVector[DenseVector[Double]] (or DenseMatrix[DenseMatrix[Double]]) and want to convert this object into an NxM's DenseMatrix object
DenseVector(DenseVector(1.0, 2.0, ...
2
votes
1answer
70 views
Using -= with incompatible types (Double and DenseVector) causes strange scala compiler error
I am rather new to scala and having encountered an initially completely uninformative NullPointerException by the scala compiler I was now able to narrow down the issue and remove it's cause, but I ...
0
votes
1answer
104 views
Adding Sparse Vectors 3.0.0 Apache Spark Scala
I am trying to create a function as the following to add
two org.apache.spark.ml.linalg.Vector. or i.e two sparse vectors
This vector could look as the following
(28,[1,2,3,4,7,11,12,13,14,15,17,20,...
1
vote
1answer
105 views
Percent point function (PPF) in scala for a normal distribution
I was wondering what is the equivalent Scala function to compute the Percent point function of a normal distribution as in python one can use the Scipy function scipy.stats.norm.ppf(x)?
2
votes
1answer
57 views
Cant Access Matrix Rows Inside DiffFunction
I am trying to run this simple program:
object Test {
def foo(args: (Double, Double, Double)*) = {
val x = DenseMatrix(args.toList :_*)
val r = DenseVector(5.0, 5.0, 0.0)
println(sum(...
0
votes
1answer
63 views
How to convert breeze densevector to seq or array
I need to convert breeze Densevector to seq or array so that I can use zipWithIndex to get index of each element.
0
votes
1answer
329 views
java.lang.NoSuchMethodError in spark-submit
After compiling my code using sbt package and submitting them in spark:
sudo -u spark spark-submit --master yarn --deploy-mode client --executor-memory 2G --num-executors 6 --class viterbiAlgorithm....
1
vote
1answer
34 views
Matrix multiplication: error: too many arguments for method *:*
scala> val B = DenseMatrix((0.5,0.2,0.3),
(0.1,0.4,0.5),
(0.25,0.35,0.4),
(0.6,0.2,0.2),
(0.7,0.1,0.2)...
0
votes
1answer
57 views
Maximize a exponential equation using scalanlp breeze optmize library
I have a formula (known as Chritoffersen test) like this:
∑(1-C(i) )(log(a * b * D(i)^(b-1))-1))
where a = ∑(1 - C(i)/∑D(i)^b
and
b is double value
The ...
0
votes
1answer
56 views
Maximum matrix size in Scala Breeze or other Java/Scala matrix packages?
I am trying to write a generic modelling code in Scala that relies on a grid (matrix or tensor). After much looking around, I decided to use Breeze for the matrix because (1) it's API is in Scala, ...
2
votes
0answers
59 views
Breeze - Apply a functions to a DenseVector to get a DenseMatrix
Given some vector of numbers, I want to apply a different function to the vector and get a matrix of the results. Is there an idiomatic way of doing this in breeze?
import breeze.linalg._
val dv = ...
0
votes
1answer
38 views
Breeze - Comparison of DenseVector gives me a BitVector - is this intentional?
import breeze.linalg._
val dm = DenseMatrix(0.0, 5.0, 6.0)
dm :== 6.0
val dv = DenseVector(0.0, 5.0, 6.0)
dv :== 6.0
gives me
dm: breeze.linalg.DenseMatrix[Double] =
0.0
...
1
vote
0answers
79 views
In Breeze, what is the best way to raise every column of a matrix to a power?
Let's say I have a matrix like [a1 a2 a3 a4], where the ai's are the columns, and a sequence of Ints like (p1, p2, p3, p4). What is the best way to create the matrix [a1^p1 a2^p2 a3^p3 a4^p4]?
...
1
vote
0answers
103 views
Error in types double and DenseVector[Double]
The following code is the answer to this question: Anomaly detection with PCA in Spark
import breeze.linalg.{DenseVector, inv}
import org.apache.spark.ml.Pipeline
import org.apache.spark.ml.feature.{...
0
votes
0answers
467 views
Symbol 'term <root>.shapeless' is missing from the classpath. This symbol is required by 'value breeze.linalg.operators.MatrixGenericOps.v1ne'
import breeze.linalg.{*, Axis, DenseVector, argmax, convert, fliplr, flipud, kron, max}
import breeze.linalg.{DenseMatrix => BDM, DenseVector => BDV}
import breeze.numerics._
import java.io.File
...
1
vote
1answer
52 views
using spire and breeze in the same project confuses intellij
I'm using intellij 2018.2 CE,
With a scala 2.12.7 project, having dependencies on spire 0.14.1 and breeze 0.13.2 in the same projet completely confuses intellij about spire.algebra typeclasses used in ...
1
vote
2answers
629 views
python numpy std vs scala breeze stddev
I'm currently working on migrating some python code to scala. I'm using breeze lib as a substitution for numpy.
Everything looks fine, but I faced different behaviour in output of standard deviation ...
3
votes
1answer
422 views
scalac :Out of memory during building Breeze
I'm trying to build Breeze by myself using Intellij IDEA
Here's my enviroment
Intellij version:2018.2.1 Community
OS:Windows 10 64-bit
JDK version:1.8.0_181
scala SDK version:2.12
sbt version: sorry.....
1
vote
1answer
135 views
How to add one to every element of a SparseVector in Breeze?
Given a Breeze SparseVector object:
scala> val sv = new SparseVector[Double](Array(0, 4, 5), Array(1.5, 3.6, 0.4), 8)
sv: breeze.linalg.SparseVector[Double] = SparseVector(8)((0,1.5), (4,3.6), (5,...
1
vote
1answer
338 views
Compatibility of Apache Spark 2.3.1 and 2.0.0
I would like to use an application developed with Apache Spark 2.0.0 (GitHub repo here) but I only have Spark 2.3.1 installed on my iMac (it seems to be the only one supported by homebrew at the ...
3
votes
2answers
134 views
How to find the mean of same cells in an array of Breeze Matrices in spark scala?
I have an Array[DenseMatrix[Double]] and i want to find the mean of the same cells. For example:
Array[0]:
+---+---+
| 1 | 2 |
+---+---+
| 2 | 3 |
+---+---+
Array[1]:
+---+---+
| 1 |...
2
votes
0answers
76 views
Import not found outside of class scope
I'm running the Scala code below in a Zeppelin notebook, on an Azure HDInsight instance.
%livy2.spark
import breeze.linalg.DenseVector
var foo: DenseVector[Double] = DenseVector.zeros[Double](1)
...
1
vote
1answer
141 views
how to implement Python's norm.expect in scala
I'm trying to implement this python function in scala. Can someone help?
The Python code is:
from scipy.stats import norm
import numpy as np
def expected_spend(mu,sigma,cl):
return norm.expect(...
0
votes
1answer
284 views
How to slice SparseVector with Breeze?
I have a SparseVector in Breeze and a given list of indices. How do I get a new SparseVector containing elements present only at those indices?
Eg:
import breeze.linalg.{Vector => BV, DenseVector ...
0
votes
1answer
98 views
Multivariate interpolation in Scala
I need to do multivariate interpolation in Scala. I am using LinearInterpolator of breeze.interpolation but cannot find a way to pass a matrix. I wonder if anyone know if it's possible?
This is what ...
0
votes
1answer
119 views
Dense matrix for 3D-shaped objects
I am fairly new to Breeze library. I am trying to convert a 3D Array of shape (2,1,40) to a dense matrix but I am not sure if I am doing it the right way.
My requirement is:
A matrix with 2 rows, 1 ...
0
votes
1answer
29 views
Breeze Linalg - efficiently map all existing values to constant
I have a breeze.linalg.SparseVector. And I want to create a new SparseVector as an output where all values are 1 (or some other constant).
How can I do it?
2
votes
1answer
271 views
scala breeze, remove column or row from matrix
Is it possible to remove one or more columns or rows from a matrix in breeze?
It's possible in matlab by setting it to an empty matrix but in breeze u get a dimension error.
1
vote
0answers
438 views
Convert an Array[org.apache.spark.sql.Row] to a DenseMatrix[Double] in scala
I have this solution which works but I wonder if there's a clever way to do it, avoiding the explicit for loop and the toString.toDouble conversion
import scala.collection.mutable.ArrayBuffer
val ...
2
votes
1answer
622 views
scala-breeze/spark replace a row of a densematrix with another densevector
I have a breeze.linalg.DenseMatrix:
breeze.linalg.DenseMatrix[Int] =
1 5 9
2 6 10
3 7 11
4 8 12
and a breeze.linalg.DenseVector:
breeze.linalg.DenseVector[Int] = DenseVector(13, ...
2
votes
1answer
2k views
Create a Breeze DenseMatrix from a List of double arrays in scala
I have a structure List[Array[Double]] and I want to convert to a DenseMatrix. I have this solution but I think there might be a better way:
val data = List[Array[Double]]
val rows = data.length;
val ...
0
votes
1answer
54 views
Different Equality[DenseVector] types for different numerical tolerances
I've written a scalactic equality provider for DenseVectors that uses the breeze closeTo method to check if each double in the vector is close enough.
implicit val vectorEquality: Equality[...
0
votes
1answer
159 views
java.lang.NoSuchMethodError: breeze.linalg.tile$.tile_DM_Impl2
I have a spark code that use breeze. I can se the breeze version of my project:
$ gradle dependencies | grep breeze
| | +--- org.scalanlp:breeze_2.11:0.12
| | | +--- org....
0
votes
1answer
80 views
Implement elementwise UFunc in Scala Breeze
I'm trying to implement my own elementwise UFunc for a Scala Breeze matrix, so that the function can be applied to each element of a matrix. Using the Breeze.numerics package as a guide I have tried:
...
0
votes
1answer
240 views
Using Scala Breeze numerics results in error: not enough arguments for method apply
I am developing a simple classification algorithm using Scala Breeze. I would like to use Breeze numerics to apply different functions to the matrices I'm working with, specifically sigmoid and tanh. ...
0
votes
1answer
398 views
Add a vector to every column of a matrix, using Scala Breeze
I have a matrix M of (L x N) rank and I want to add the same vector v of length L to every column of the matrix. Is there a way do this please, using Scala Breeze?
I tried:
val H = DenseMatrix.zeros(...
2
votes
1answer
903 views
Can Spark and the ScalaNLP library Breeze be used together?
I'm developing a Scala-based extreme learning machine, in Apache Spark. My model has to be a Spark Estimator and use the Spark framework in order to fit into the machine learning pipeline. Does anyone ...
1
vote
1answer
132 views
SBT Compiler crash using Scala-Breeze
I am writing a code to perform kernel K-Means (aka https://en.wikipedia.org/wiki/K-means_clustering, but with a trick). I need to generate data, and as a first simple generator I tried to implement a ...
0
votes
2answers
156 views
java.lang.ClassNotFoundException: breeze.generic.UFunc$UImpl2 when using Breeze DenseVector
Using Breeze I get a runtime error:
Java.lang.ClassNotFoundException: breeze.generic.UFunc $ UImpl2.
I can not understand what I'm wrong about, and unfortunately my online searches did not help me. ...
1
vote
2answers
159 views
Is there a more Scala-esque way to impelent this vector processing function?
I'm really new to Scala, and I've been trying to implement a function which is given two Scala Breeze DenseVectors that are equal length. Both vectors contain double values and NaNs. The function ...
0
votes
1answer
68 views
Scala Breeze does not find my file on a webserver, while Java does
I'm new to Scala, so there's probably something obvious I'm missing.
I've got a Scalatra webserver running, with a csv-file in the same folder as the Scalatra servlet. The webserver recognizes the ...
0
votes
1answer
114 views
Jacobian in Scala
Is there a way/library to calculate Jacobian in Scala similar to Jacobian function inside numDeriv package in R? I am using Breeze, but I was unable to find anything related to Jacobian in it.
For ...
0
votes
3answers
109 views
Scala referencing function in another function
I am relatively new to Scala, been using R and MATLAB before. I have written the following piece of code in Scala. I've written the same code in R and MATLAB, and in both it works just fine, but due ...
4
votes
2answers
858 views
How to replace elements of a breeze matrix in Scala based on some condition?
I am working with 2 dimensional Breeze matrices in Scala. At some point I have to do element-wise division of two matrices. Some elements in the denominator matrix can be zero, resulting into NaNs in ...
1
vote
2answers
1k views
how to calculate the Inverse of the normal cumulative distribution function (cdf) using scala breeze?
I would like to calculate Inverse of the normal cumulative distribution function (cdf) using scala breeze similar to MATLAB function NORMINV. But i did not find any builtin function to calculate it. ...
0
votes
1answer
126 views
Scala JSON to DenseMatrix
I am trying to convert this JSON response:
[
{
"metric":"energy.salted",
"tags":{
"sensor":"0",
"unit":"101"
},
"aggregateTags":[
],
"...
1
vote
1answer
1k views
Converting matrix to array row by row in Breeze
Trying to convert a DenseMatrix to an array row by row. Method .toArray does it column by column.
-0.04202212765812874 0.001493146410211921 0.06454376876354218
-0.0281160194426775 -0....
0
votes
1answer
910 views
force dependency update in build.sbt
I am using breeze-viz 0.3, but need to use newer version of jfreechart. According to the dependency table
https://mvnrepository.com/artifact/org.scalanlp/breeze-viz_2.10/0.3
jfreechart 1.0.13 is ...
0
votes
1answer
332 views
Updating scala breeze matrix for point with x,y coordinates (NOT length of rows and cols)
I'm new to Scala (Python background) and trying to implement a Quadtree for my sparse data and attempting to use Breeze to do so (although if you have a better suggestion, I'm totally open to it).
...
2
votes
1answer
408 views
Scala Breeze Cartesian product of vectors
Let's say I have 2 vectors of the same dimensionality:
scala> val v = DenseVector(3.0, 4.0)
v: breeze.linalg.DenseVector[Double] = DenseVector(3.0, 4.0)
scala> val w = DenseVector(5.0, 6.0)
w: ...