O'Reilly logo

Machine Learning with Spark - Second Edition by Nick Pentreath, Manpreet Singh Ghotra, Rajdeep Dua

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Evaluating k for SVD on the LFW dataset

We will examine the singular values obtained from computing the SVD on our image data. We can verify that the singular values are the same for each run, and that they are returned in a decreasing order, as follows:

val sValues = (1 to 5).map {   i => matrix.computeSVD(i,  computeU = false).s } sValues.foreach(println)

This last code should generate an output similar to the following:

[54091.00997110354][54091.00997110358,33757.702867982436][54091.00997110357,33757.70286798241,24541.193694775946][54091.00997110358,33757.70286798242,24541.19369477593, 23309.58418888302][54091.00997110358,33757.70286798242,24541.19369477593, 23309.584188882982,21803.09841158358]

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required