Permalink
Browse files

fix datatype, suppress item being viewed

  • Loading branch information...
1 parent 732541a commit c7ac118b55fc3b86f7ca1f4c44e32cd0a74533f9 @elliottcordo elliottcordo committed Mar 29, 2014
Showing with 16 additions and 10 deletions.
  1. +1 −1 config.cnf
  2. +1 −0 mahout_cmds/itemsimilarity.sh
  3. +8 −7 rpm/rpm.py
  4. +6 −2 sample_etl/mahout_item_sim_to_redis.pig
View
@@ -8,4 +8,4 @@ terminal=1
[rpm]
itembase_bias=1.00
-itemsim_bias=1.25
+itemsim_bias=1.00
@@ -3,6 +3,7 @@
#remove files
hadoop fs -rmr /user/movie_lens_rec_item_similarity
hadoop fs -rmr /app/hadoop/tmp/recommenditemsimilarity
+
#run hadoop
/usr/local/hadoop/mahout/bin/mahout itemsimilarity \
--input /user/movie_lens_data \
View
@@ -104,11 +104,11 @@ def get_items():
##################################
#recommendation getters
-@app.route('/recommenderitems/<string:userid>/<int:itemid>/<int:numitems>/<string:mode>')
-@app.route('/recommenderitems/<string:userid>/<int:itemid>/<int:numitems>',defaults={'mode': 'simple'})
+@app.route('/recommenderitems/<string:userid>/<string:itemid>/<int:numitems>/<string:mode>')
+@app.route('/recommenderitems/<string:userid>/<string:itemid>/<int:numitems>',defaults={'mode': 'simple'})
#http://127.0.0.1:5000/recommenderitems/572/7/50/detail or http://127.0.0.1:5000/recommenderitems/572/7/50
-def recommenderitems (userid, itemid, numitems,mode):
+def recommenderitems (userid, itemid, numitems, mode):
retArray = []
@@ -129,10 +129,11 @@ def recommenderitems (userid, itemid, numitems,mode):
factor = 1
for i in itembase:
- item = dict()
- item['item_id'] = i[0]
- item['score'] = i[1] * itembase_bias
- retArray.append(item)
+ if i[0] != itemid: #suppress the item the user is viewing
+ item = dict()
+ item['item_id'] = i[0]
+ item['score'] = i[1] * itembase_bias
+ retArray.append(item)
for i in itemsim:
this_itemid = i[0]
@@ -6,7 +6,11 @@ raw = LOAD '/user/movie_lens_rec_item_similarity'
USING PigStorage('\t') as (item1:chararray, item2:chararray, rating:chararray);
exp_tuple = FOREACH raw GENERATE item1, TOTUPLE(item2, rating);
-
-STORE exp_tuple INTO 'dummy' USING com.hackdiary.pig.RedisStorer('zset','192.168.56.1');
+
+exp_tuple2 = FOREACH raw GENERATE item2, TOTUPLE(item1, rating);
+
+result = UNION exp_tuple, exp_tuple2;
+
+STORE result INTO 'dummy' USING com.hackdiary.pig.RedisStorer('zset','192.168.56.1');

0 comments on commit c7ac118

Please sign in to comment.