Questions tagged [scala-breeze]

Breeze is a linear algebra library for Scala.

Filter by
Sorted by
Tagged with
1 vote
2 answers
248 views

ClassNotFoundException: breeze.storage.Zero$DoubleZero$

I'm trying to run a distributed Kmeans using a distributed Kmeans of Spark MLLIB and I'm getting the following error: Caused by: java.lang.ClassNotFoundException: breeze.storage.Zero$DoubleZero$ ...
Reda20's user avatar
  • 53
0 votes
0 answers
45 views

Apply function on two breeze matrices

I would like to apply a function on two matrices like there is a + for the addition of two matrices. Something like matrix1.map2(matrix2) { (valM1, valM2) => valM1 + valM2 } giving a result matrix.
Sven's user avatar
  • 85
0 votes
1 answer
52 views

Compute softmax using breeze

I am constructing a deep neural network from scratch and I want to implement the softmax http://neuralnetworksanddeeplearning.com/chap3.html#softmax distributed function. I am using breeze for that ...
ezl's user avatar
  • 23
0 votes
1 answer
25 views

Generating same set of random DenseVector from Apache dictributions - Breeze

I am trying to generate a repeatable random DenseVector for a number of distributions. For the native Breeze distributions (Gaussian, Uniform), this is what I am doing: implicit val randBasis = ...
Samik R's user avatar
  • 1,636
0 votes
2 answers
88 views

Can't create Breeze DenseMatrix with Scala3

When trying to create a dense matrix of type Option with Scala 3 I receive an error. val dm1 = DenseMatrix((1,2),(1,2)) // <- this works val dm2 = DenseMatrix((Some(1),Some(2)),(Some(1),Some(...
Sven's user avatar
  • 85
0 votes
1 answer
72 views

Problem with evidence parameters in breeze

I'm trying to build a DenseMatrix of Vectors in breeze. However I keep getting the error message: could not find implicit value for evidence parameter of type breeze.storage.Zero[breeze.linalg....
Steve Gailey's user avatar
0 votes
1 answer
170 views

Scala breeze error: could not find implicit value for parameter

I'm using the breeze package on scala. I simply want do to a matrix product: A*At. However I get this error: could not find implicit value for parameter op: breeze.linalg.operators.OpMulMatrix.Impl2[...
Francesco Borg's user avatar
1 vote
0 answers
40 views

Scala Breeze matrix outer product

I am aware that in Breeze it is possible to calculate the outer product between two vectors using the * operator and transposing one of them. I couldn’t find anything about matrices though. Do you ...
amarchin's user avatar
  • 2,054
0 votes
1 answer
38 views

Does anyone knows how to create a DenseVector[Double] using Breeze library in scala

I want to create data that have a form of List[DenseVector[Double]] using scala and Breeze library. The initial data are loaded with json4s, so they have a form of List(Jarray(JDouble) does anyone ...
Reda20's user avatar
  • 53
0 votes
1 answer
41 views

Generic method that take as input Breeze Vector or Breeze Matrix

I am trying to implement a method that can accept as input either a Breeze Vector or a Breeze Matrix. Something like private def updateExponentialMovingAverage[T](tau: Double, initTheta: T, theta: T)...
amarchin's user avatar
  • 2,054
1 vote
1 answer
178 views

Counting non-zero elements in a sparse matrix using breeze

I'm new to breeze. I can't seem to be able to count the number of non-zero element per row in a CSCMatrix. Let's take the following example : val matrix = CSCMatrix.tabulate(3, 2)((x,y) => x*y) ...
Skyris's user avatar
  • 155
0 votes
0 answers
193 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, ...
lemanli's user avatar
  • 119
2 votes
1 answer
213 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 ...
Beztix's user avatar
  • 21
0 votes
1 answer
575 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,...
Sajeed's user avatar
  • 119
1 vote
1 answer
422 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)?
Galuoises's user avatar
  • 2,670
2 votes
1 answer
67 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(...
Michael's user avatar
  • 437
0 votes
1 answer
357 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.
Jack Chen's user avatar
1 vote
1 answer
1k 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....
Jack Chen's user avatar
1 vote
1 answer
135 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)...
Jack Chen's user avatar
0 votes
1 answer
152 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 ...
Imran K's user avatar
  • 81
0 votes
1 answer
161 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, ...
cedric's user avatar
  • 11
2 votes
0 answers
172 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 = ...
Simon's user avatar
  • 323
0 votes
1 answer
112 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 ...
Simon's user avatar
  • 323
1 vote
0 answers
118 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]? ...
Alexander Guldemond's user avatar
1 vote
0 answers
202 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.{...
Yhprums's user avatar
  • 189
0 votes
0 answers
833 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 ...
vinoth's user avatar
  • 1
1 vote
1 answer
81 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 ...
remi's user avatar
  • 566
1 vote
2 answers
953 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 ...
Normal's user avatar
  • 1,357
3 votes
1 answer
735 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.....
LtChang's user avatar
  • 135
1 vote
1 answer
252 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,...
kingledion's user avatar
  • 2,283
1 vote
1 answer
371 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 ...
ac2051's user avatar
  • 354
3 votes
2 answers
238 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 |...
mkey's user avatar
  • 55
2 votes
0 answers
88 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) ...
road_rash's user avatar
  • 133
1 vote
1 answer
255 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(...
Paulo Borges's user avatar
0 votes
1 answer
437 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 ...
Sai Kiriti Badam's user avatar
0 votes
1 answer
126 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 ...
zmicer's user avatar
  • 1
0 votes
1 answer
234 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 ...
Rahul Kumar's user avatar
0 votes
1 answer
37 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?
Daniil Andreyevich Baunov's user avatar
2 votes
1 answer
427 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.
user25470's user avatar
  • 585
1 vote
0 answers
574 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 ...
MLeiria's user avatar
  • 603
3 votes
1 answer
998 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, ...
8u88y's user avatar
  • 33
3 votes
1 answer
3k 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 ...
MLeiria's user avatar
  • 603
0 votes
1 answer
79 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[...
shadow chris's user avatar
0 votes
1 answer
295 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....
Tiago Albineli Motta's user avatar
0 votes
1 answer
125 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: ...
LucieCBurgess's user avatar
0 votes
1 answer
318 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. ...
LucieCBurgess's user avatar
0 votes
1 answer
614 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(...
LucieCBurgess's user avatar
3 votes
1 answer
1k 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 ...
LucieCBurgess's user avatar
1 vote
1 answer
185 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 ...
vkubicki's user avatar
  • 1,104
0 votes
2 answers
308 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. ...
andrew's user avatar
  • 1