make a recommendation machine item to item

18 views
Skip to first unread message

Messaoud Mohamed

unread,
May 18, 2016, 2:17:07 PM5/18/16
to scala-user
Hello 
I'm new in sprk mlib and i want to make a recommendation engine with it.
But the problem that i'm using orientdb wich make the id for vertices and edges automaticaly.
and i want to recommend user to user
the data are stored in graph database
i make the connector and it work but how can i get the nodes of vertic user from it and make recommendation machine user to user ?


val insta = sc.orientGraph()





//************Get only the class User from the Graph with edges and map the String id to LONGid*********************

val userRDD = sc.orientQuery("User")

// Assign unique Long id for each userId
val userIdToInt: RDD[(String, Long)] = userRDD.map(_.oRid).distinct().zipWithUniqueId()
userIdToInt.foreach(println)





//***********************Working with mlib ******************************************************************
val aMatrix = new DoubleMatrix(Array(1.0, 2.0, 3.0))

def cosineSimilarity(vec1: DoubleMatrix, vec2: DoubleMatrix): Double = { vec1.dot(vec2) / (vec1.norm2() * vec2.norm2()) }
Reply all
Reply to author
Forward
0 new messages