Skip to main content

All Questions

Tagged with
1 vote
0 answers
46 views

Get compiler to notice exhaustive match on Vector

The following code defines an exhaustive match over a Vector, v. def testExhaustiveness(v: Vector[Int]) = { v match { case Vector() => println("v is empty") case ns :+ n => ...
doliphin's user avatar
  • 959
0 votes
0 answers
19 views

VectorAssembler gives struct type output instead of vector type

I'm converting two columns of double type to a vector using VectorAssembler but I'm getting a struct with all the vector parameters as the output. This is the code for the vector transform val ...
P201_eng's user avatar
0 votes
1 answer
49 views

Scala - How to keep multiple values only once and remove other redundant values from a map

Given an input map as below: val inputVal = Map( 0 -> Vector(("a", (0,1)),("b",(0,2)),("a",(2,3)),("c",(1,1))), 1 -> Vector(("a", (0,1)),(&...
Hima_93's user avatar
  • 51
1 vote
1 answer
50 views

Does Scala's Vector add any new methods on top of those provided by Seq and other superclasses?

Are there any methods in Scala's Vector that are not declared by its superclasses like AbstractSeq? I am working on providing language localization (translation) for a learning environment/IDE built ...
Ben Bulent Basaran's user avatar
0 votes
1 answer
68 views

Unable to "explode" spark vector from PCA

I am trying to scatter plot the 2 features resulting from the PCA in spark ml library. To be more precise I am trying to convert result into something like this: _________ id | X | Y __________ 1 |0....
Rems Vuagn's user avatar
0 votes
1 answer
247 views

Functional way to build a matrix from the list in scala

I've asked this question on https://users.scala-lang.org/ but haven't got a concrete answer yet. I am given a vector v and I would like to construct a matrix m based on this vector according to the ...
yarchik's user avatar
  • 367
0 votes
1 answer
178 views

How to convert a DataFrame to an Array of dense vectors?

How would I convert the following DataFrame val df = Seq( (5.0, 1.0, 1.0, 3.0, 7.0), (2.0, 0.0, 3.0, 4.0, 5.0), (4.0, 0.0, 0.0, 6.0, 7.0)).toDF("m1", "m2", "m3", &...
Amazonian's user avatar
  • 455
1 vote
2 answers
113 views

How do I use the forall loop to check if all rows have the same number of columns in a Vector in Scala?

So I have a generic vector: 1:vec: Vector[Vector[T]] Now I wanna use the require and forall to check if the length of each row is the same. This is how far I've gotten: 2:require(vec.forall(row => ...
Tarmiac's user avatar
  • 852
0 votes
1 answer
560 views

row to vector in scala spark

I have a row that is obtained in the following way: val row_name = df.collect()(i) how can I convert this row to a type vector so that it can be passed to fromML() as follows ? val vector_name=org....
user9875189's user avatar
0 votes
0 answers
40 views

Data structure that allows efficient equality checks for closely related sequences (common subsequences)

I'm looking for a data structure that I can use for Snapshot (a sequence) in the following example: val oldSnapshot = Snapshot(3, 2, 1) val newSnapshot = 4 +: (oldSnapshot dropRight 1) // basically a ...
lex82's user avatar
  • 11.2k
1 vote
2 answers
1k views

Performance : Vector vs ArrayBuffer vs Array

Scala 2.11.4 - While trying to solve this problem "Sliding Window Maximum", I wrote this code : def slidingMaximum(A: Array[Int], B: Int): Array[Int] = { var ans = Vector[Int]() ...
Saurav Sahu's user avatar
  • 13.7k
0 votes
1 answer
90 views

Operation on normalVectorRDD

I want to create an RDD[Vector] with my own mean and my own sigma, i have done this : val mean = Random.nextInt(100) val sigma = 2 val data: RDD[Vector] = RandomRDDs.normalVectorRDD(sc, numRows = 180, ...
Wilson Wii's user avatar
1 vote
2 answers
278 views

Scala append value to multiple vector

I create a multiple vector like this: val a = Vector.fill(3,0)(0) It outputs: Vector(Vector(), Vector(), Vector(), Vector(), Vector(), Vector()) I want to append an integer value into the first ...
Dani's user avatar
  • 11
0 votes
1 answer
334 views

How to map over a Spark Vector?

I have a mllib.linalg.Vector in Scala containing Double values in range of (-1; 1). I would like to multiply all of the values by, let's say, 100. For example I'd like to convert [0.5, 0.3, -0.1] to [...
radrow's user avatar
  • 6,849
0 votes
1 answer
188 views

Concrete and abstract Vector classes

I went trough scaladoc and found something that I find strange and I cannot explain. There is the sealed abstract class Vector with its companion object Vector. Looking through Vector.scala it ...
Kilian Scheltat's user avatar

15 30 50 per page
1
2 3 4 5
9