Saturday 15 September 2012

How to export mllib als results into text file Spark -



How to export mllib als results into text file Spark -

i'm new in spark. i'm trying run collaborative filtering algorithm , made it. want know how can set users recommendations text file or mysql info set?

for illustration in spark shell:

scala> topkrecs.mkstring("\n") res3: string = rating(101168482,976126,17.762857135595247) rating(101168482,298077,15.618423165870723) rating(101168482,269474,15.20514216060495) rating(101168482,992979001,14.874869183497482) rating(101168482,302470001,14.794531500898763) rating(101168482,303592,14.779064871786169) rating(101168482,1538670001,13.96013790139799) rating(101168482,458919,13.905207127505795) rating(101168482,1141423,13.882807601308972) rating(101168482,992981003,13.844550596026654)

you in 2 ways: 1 store rating objects ie:

topkrecs.saveasobjectfile("path")

2 store values output file

topkrecs.map(rating => (rating.user, rating.product, rating.rating)).saveastextfile("path")

apache-spark

No comments:

Post a Comment