Skip to content

Commit

Permalink
use sampleByKey for per user sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
Debasish Das committed Nov 8, 2014
1 parent 10cbb37 commit f38a1b5
Showing 1 changed file with 1 addition and 2 deletions.
Expand Up @@ -141,9 +141,8 @@ object MovieLensALS {

println(s"Got $numRatings ratings from $numUsers users on $numMovies movies.")

//val splits = ratings.randomSplit(Array(0.8, 0.2))
val fractions = (0 until numUsers.toInt).map(x => (x + 1, 0.8)).toMap

val training = ratings.map { x => (x.user, x) }.sampleByKey(false, fractions).map { x => x._2 }
val testSplit = ratings.subtract(training)

Expand Down

0 comments on commit f38a1b5

Please sign in to comment.