Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning Apache Mahout

You're reading from  Learning Apache Mahout

Product type Book
Published in Mar 2015
Publisher
ISBN-13 9781783555215
Pages 250 pages
Edition 1st Edition
Languages

In-core types


Vector and Matrices are of type in-core or in-memory. We will try out some basic commands to get a feel of the linear algebra operations possible.

Vector

We will first discuss vectors and then cover matrices. We will see some examples of operations that can be performed on vectors.

Initializing a vector inline

Dense vector: The dense vector is a vector with relatively fewer zero elements. On the Mahout command line, please type the following command to initialize a dense vector:

mahout>val denseVec1: Vector = (1.0, 1.1, 1.2)

Each element is prefixed by its index, which starts with 0. The output of the command executed is given as follows:

denseVec1: org.apache.mahout.math.Vector = {0:1.0,1:1.1,2:1.2}

Sparse vector: Sparse vector is a vector with a relatively large number of zero elements. On the Mahout command line, please type the following command to initialize a sparse vector:

mahout>val sparseVec = svec((5 -> 1) :: (10 -> 2.0) :: Nil)

The output of the command...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}