Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Hands-On Exercise: Using a Mahout

Recommender
In  this  exercise  you  will  use  Mahout  to  generate  movie  recommendations  for  users.  

1.   Ensure  that  you  completed  the  Sqoop  Hands-­‐On  Exercise  to  import  the  movie  
and  movierating  data.  

2.   Create  a  list  of  users  for  whom  you  want  to  generate  recommendations,  by  
creating  and  editing  a  file  on  your  local  disk  named  users.  Into  that  file,  on  
separate  lines  place  the  user  IDs  6037,  6038,  6039,  6040,  so  that  the  file  looks  
like  this:  

6037
6038
6039
6040

Important:  Make  sure  there  is  not  a  blank  line  at  the  end  of  the  file.  The  
line  containing  the  last  user  ID  should  not  have  a  carriage  return  at  the  
end  of  that  line.  If  it  does,  the  job  will  fail.  

3.   Upload  the  file  to  HDFS:  

$ hadoop fs -put users users

4.   Run  Mahout’s  item-­‐based  recommender:  

$ mahout recommenditembased --input movierating \


--output recs --usersFile users \
--similarityClassname SIMILARITY_LOGLIKELIHOOD

5.   This  will  take  a  long  time  to  execute;  it  runs  approximately  10  MapReduce  jobs.  
Your  instructor  will  now  continue  with  the  notes,  but  when  the  final  job  is  

Copyright © 2010-2013 Cloudera, Inc. All rights reserved. 42


Not to be reproduced without prior written consent.
complete,  investigate  the  part-r-00000  file  in  your  newly-­‐created  recs  
directory.  

$ hadoop fs -cat recs/part-r-00000


6037
[2010:5.0,1036:5.0,1035:5.0,3703:5.0,2076:5.0,3108:5.0
,1028:5.0,3105:5.0,3104:5.0,2064:5.0]
6038
[671:5.0,2761:5.0,745:5.0,741:5.0,720:5.0,2857:5.0,838
:5.0,3114:5.0,3044:5.0,3000:5.0]
6039
[1946:5.0,1036:5.0,1035:5.0,3703:5.0,1032:5.0,2078:5.0
,3114:5.0,1029:5.0,1028:5.0,2076:5.0]
6040
[2610:5.0,1904:5.0,3910:5.0,3811:5.0,6:5.0,3814:5.0,16
:5.0,17:5.0,1889:5.0,3794:5.0]

This is the end of the Exercise

Copyright © 2010-2013 Cloudera, Inc. All rights reserved. 43


Not to be reproduced without prior written consent.

You might also like