30. [Activity] Running the Similiar Movies Script using Spark's Cluster Manager
Activity
Looking At The Code
println("\nLoading movie names...") val nameDict = loadMovieNames() /** Load up a Map of movie IDs to movie names. */ def loadMovieNames() : Map[Int, String] = { // Handle character encoding issues: implicit val codec = Codec("UTF-8") codec.onMalformedInput(CodingErrorAction.REPLACE) codec.onUnmappableCharacter(CodingErrorAction.REPLACE) // Create a Map of Ints to Strings, and populate it from u.item. var movieNames:Map[Int, String] = Map() val lines = Source.fromFile("../ml-100k/u.item").getLines() for (line <- lines) { var fields = line.split('|') if (fields.length > 1) { movieNames += (fields(0).toInt -> fields(1)) } } return movieNames }
To Run The Code And Pass In An Argument
Previous29. Item-Based Collaborative Filtering in Spark, cache(), and persist()Next31. [Exercise] Improve the Quality of Similiar Movies
Last updated