Ejemplo n.º 1
0
Created on Nov 24, 2015

@author: ola
'''
import RecommenderEngine, json
import SimpleFoodReader
import BookReader
import MovieReader

if __name__ == "__main__":
    #(jitems,jratings) = SimpleFoodReader.getData("foodratings_example.txt")
    (jitems, jratings) = BookReader.getData("bookratings.txt")
    #(jitems,jratings) = MovieReader.getData("movieratings.txt")
    print "items = ", jitems
    print "ratings = ", jratings

    items = json.loads(jitems)
    ratings = json.loads(jratings)

    avg = RecommenderEngine.averages(items, ratings)
    print avg

    for key in ratings:
        slist = RecommenderEngine.similarities(key, ratings)
        print key, slist
        print "\t", RecommenderEngine.scores(slist, items, ratings, 1)
        print "\t", RecommenderEngine.scores(slist, items, ratings, len(slist))

    print RecommenderEngine.recommend(ratings.keys()[0], items, ratings, 5)
    #for the above test, I randomly chose a name and a count
Ejemplo n.º 2
0
Created on Nov 24, 2015

@author: ola
'''
import RecommenderEngine, json
import SimpleFoodReader
import BookReader
import MovieReader

if __name__ == "__main__":
    #(jitems,jratings) = SimpleFoodReader.getData("foodratings_example.txt")
    (jitems,jratings) = BookReader.getData("bookratings.txt")
    #(jitems,jratings) = MovieReader.getData("movieratings.txt")
    print "items = ",jitems
    print "ratings = ", jratings
    
    items = json.loads(jitems)
    ratings = json.loads(jratings)
    
    avg = RecommenderEngine.averages(items,ratings)
    print avg
     
    for key in ratings:
        slist = RecommenderEngine.similarities(key,ratings)
        print key,slist
        print "\t",RecommenderEngine.scores(slist,items,ratings,1)
        print "\t",RecommenderEngine.scores(slist,items,ratings,len(slist))
        
    print RecommenderEngine.recommend(ratings.keys()[0], items, ratings, 5)
    #for the above test, I randomly chose a name and a count
Ejemplo n.º 3
0
'''
Created on Dec 4, 2015

@author: Jonathan Yu
'''
import RecommenderEngine, json
import MovieReader
import random

if __name__ == "__main__":
    (jitems,jratings) = MovieReader.getData("movieratings.txt")
    
    items = json.loads(jitems)
    ratings = json.loads(jratings)
    
    name = ratings.keys()[random.randint(0, len(ratings) + 1)]
    count = 15
    recs = RecommenderEngine.recommend(name, items, ratings, count)
    recs = ", ".join(d[0] for d in recs[:10])
    print "Using " + str(count) + " other users' ratings, our top ten recommendations for " + name + " are " + recs + "."
    
    print
    
    name = ratings.keys()[random.randint(0, len(ratings) + 1)]
    count = 20
    recs = RecommenderEngine.recommend(name, items, ratings, count)
    recs = ", ".join(d[0] for d in recs[:10])
    print "Using " + str(count) + " other users' ratings, our top ten recommendations for " + name + " are " + recs + "."
import RecommenderEngine, json
import SimpleFoodReader

if __name__ == "__main__":
    (jitems, jratings) = SimpleFoodReader.getData("foodratings_example.txt")
    print "items = ", jitems
    print "ratings = ", jratings

    items = json.loads(jitems)
    ratings = json.loads(jratings)

    avg = RecommenderEngine.averages(items, ratings)
    # print avg

    for key in ratings:
        slist = RecommenderEngine.similarities(key, ratings)
        print key, slist
        print "\t", RecommenderEngine.scores(slist, items, ratings, 1)
        print "\t", RecommenderEngine.scores(slist, items, ratings, len(slist))
        print "\t", RecommenderEngine.recommend(key, items, ratings, 3)
Ejemplo n.º 5
0
@author: Jonathan Yu
'''
import RecommenderEngine, json
import MovieReader
import random

if __name__ == "__main__":
    (jitems, jratings) = MovieReader.getData("movieratings.txt")

    items = json.loads(jitems)
    ratings = json.loads(jratings)

    name = ratings.keys()[random.randint(0, len(ratings) + 1)]
    count = 15
    recs = RecommenderEngine.recommend(name, items, ratings, count)
    recs = ", ".join(d[0] for d in recs[:10])
    print "Using " + str(
        count
    ) + " other users' ratings, our top ten recommendations for " + name + " are " + recs + "."

    print

    name = ratings.keys()[random.randint(0, len(ratings) + 1)]
    count = 20
    recs = RecommenderEngine.recommend(name, items, ratings, count)
    recs = ", ".join(d[0] for d in recs[:10])
    print "Using " + str(
        count
    ) + " other users' ratings, our top ten recommendations for " + name + " are " + recs + "."
'''
Created on Nov 28, 2015

@author: tedmarchildon
'''

import RecommenderEngine, json
import BookReader

if __name__ == "__main__":
    (jitems,jratings) = BookReader.getData("bookratings.txt")
    print "items = ",jitems
    print "ratings = ", jratings
    
    items = json.loads(jitems)
    ratings = json.loads(jratings)
    
    avg = RecommenderEngine.averages(items,ratings)
    #print avg
     
    for key in ratings:
        slist = RecommenderEngine.similarities(key,ratings)
        print key,slist
        print "\t",RecommenderEngine.scores(slist,items,ratings,1)
        print "\t",RecommenderEngine.scores(slist,items,ratings,len(slist))
        print '\t', RecommenderEngine.recommend(key, items, ratings, 3)