Questions tagged [scala-breeze]

Breeze is a linear algebra library for Scala.

Breeze is a linear algebra library for Scala.

From the project's GitHub page:

Breeze is a library for numerical processing, machine learning, and natural language processing. Its primary focus is on being generic, clean, and powerful without sacrificing (much) efficiency. Breeze is the merger of the ScalaNLP and Scalala projects, because one of the original maintainers is unable to continue development.

197 questions
1
vote
2 answers

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$ at…
1
vote
0 answers

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 have any suggestions? The question about vectors…
amarchin
  • 2,044
  • 1
  • 16
  • 32
1
vote
1 answer

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) This is a sparse matrix of dimension…
Skyris
  • 155
  • 1
  • 9
1
vote
1 answer

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
  • 2,630
  • 24
  • 30
1
vote
1 answer

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.viterbiAlgo…
Jack Chen
  • 77
  • 7
1
vote
1 answer

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)) scala> (B *:* B)(::,1) :38: error: too…
Jack Chen
  • 77
  • 7
1
vote
0 answers

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]? Ultimately, the output I need is a vector where the…
1
vote
0 answers

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.{PCA, StandardScaler,VectorAssembler} import…
Yhprums
  • 189
  • 1
  • 11
1
vote
1 answer

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 my code (Ring, Order, Eq, Semiring, etc) (Symbol…
remi
  • 566
  • 3
  • 13
1
vote
2 answers

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 implementations: Python: series =…
Normal
  • 1,347
  • 4
  • 17
  • 34
1
vote
1 answer

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,0.4)) What is the best way to take the log of the…
kingledion
  • 2,263
  • 3
  • 25
  • 39
1
vote
1 answer

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 moment). I can successfully compile it with sbt…
ac2051
  • 354
  • 1
  • 2
  • 15
1
vote
1 answer

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(lambda x:…
1
vote
0 answers

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 rows: Array[Row] = df2.collect() //rows:…
MLeiria
  • 633
  • 1
  • 9
  • 22
1
vote
1 answer

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 Gaussian Mixture Model. Here are my code: package…
vkubicki
  • 1,104
  • 1
  • 11
  • 26