Beispiel #1
0
        print "Length of new_prefs %d"%(len(new_prefs))
        
        print 'Doing CBR...'
        sparsity.caseone_doFillUsingCBR(new_prefs, deleted_users)
        print 'Doing Average Filling...'
        sparsity.caseone_doAverageFilling(new_prefs, deleted_users)

        #use the original prefs here.
        print 'Calculating original item similarity...'
        oitemsim = original.calculateSimilarItems(org_prefs, n=50)

        #use the modified prefs here.
        print 'Calculating algorithm item similarity...'
        itemsim = algorithm.calculateSimilarItems(new_prefs, n=50)

        print 'Calculating original ranking...'
        oranking = original.getRecommendedItems(org_prefs, oitemsim,str(user))
        print 'Calculating algorithm ranking...'
        
        ranking = original.getRecommendedItems(new_prefs,itemsim,str(user))

        print 'Calculating MAE for original...'
        original_MAE.append(calMAE(oranking,str(user)))

        print 'Calculating MAE for algorithm...'
        algorithm_MAE.append(calMAE(ranking,str(user)))

    
    print original_MAE
    print algorithm_MAE
Beispiel #2
0
        print "Length of new_prefs %d" % (len(new_prefs))

        print 'Doing CBR...'
        sparsity.caseone_doFillUsingCBR(new_prefs, deleted_users)
        print 'Doing Average Filling...'
        sparsity.caseone_doAverageFilling(new_prefs, deleted_users)

        #use the original prefs here.
        print 'Calculating original item similarity...'
        oitemsim = original.calculateSimilarItems(org_prefs, n=50)

        #use the modified prefs here.
        print 'Calculating algorithm item similarity...'
        itemsim = algorithm.calculateSimilarItems(new_prefs, n=50)

        print 'Calculating original ranking...'
        oranking = original.getRecommendedItems(org_prefs, oitemsim, str(user))
        print 'Calculating algorithm ranking...'

        ranking = original.getRecommendedItems(new_prefs, itemsim, str(user))

        print 'Calculating MAE for original...'
        original_MAE.append(calMAE(oranking, str(user)))

        print 'Calculating MAE for algorithm...'
        algorithm_MAE.append(calMAE(ranking, str(user)))

    print original_MAE
    print algorithm_MAE
Beispiel #3
0
    #    training[str(key + 1)] = original_prefs[str(key+1)]

    cid = 'two'

    for user in validation:
        user_dict, removed_items = getRemovedPrefs(validation[user], 10)

        org_prefs = {}
        org_prefs = validation
        org_prefs[user] = user_dict
        print "Length of org_prefs %d" % (len(org_prefs))

        #use the original prefs here.
        print 'Calculating original item similarity...'
        oitemsim = pickle.load(
            open('../pickle/original/oitemsim_' + cid + '.pickle', "rb"))
        #oitemsim = original.calculateSimilarItems(org_prefs, n=50)

        print 'Calculating original ranking...'
        oranking = original.getRecommendedItems(org_prefs, oitemsim, user)

        print 'Calculating MAE for original...'
        original_MAE.append(getMAE(oranking, user, 'org'))

    #print original_MAE
    #print algorithm_MAE
    print sum(original_MAE) / len(original_MAE)

    pickle.dump(orgdetails,
                open("../rating_details/" + cid + "/orgdetails_" + cid, "wb"))
Beispiel #4
0
        istart = time.time()
        itemsim = algorithm.calculateSimilarItems(clusterPrefs, n=50)
        istop = time.time()

        for user in clusterPrefs:

            #fix missing values
            if not user:
                continue

            print "Cluster: %d User: %s" % (cid, user)

            rstart = time.time()
            #ranking = algorithm.getRecommendedItems(testingPrefs, clusterPrefs,itemsim,user)
            ranking = original.getRecommendedItems(testingPrefs, itemsim, user)
            rstop = time.time()

            orstart = time.time()
            oranking = original.getRecommendedItems(testingPrefs, oitemsim,
                                                    user)
            orstop = time.time()

            print '**************STATS****************'
            print 'algo item sim: %d s' % (abs(istart - istop))
            print 'orig item sim: %d s' % (abs(ostart - ostop))
            print 'algo reco time: %d s' % (abs(rstart - rstop))
            print 'orig reco time: %d s' % (abs(orstart - orstop))
            print '**************END STATS************'

            original_MAE.append(getMAE(oranking, user))
Beispiel #5
0
    cid = 'two'
    
    for user in validation:
        user_dict, removed_items = getRemovedPrefs(validation[user], 10)
        
        
        org_prefs = {}
        org_prefs = validation
        org_prefs[user] = user_dict
        print "Length of org_prefs %d"%(len(org_prefs))
        
        
        #use the original prefs here.
        print 'Calculating original item similarity...'
        oitemsim = pickle.load( open( '../pickle/original/oitemsim_' + cid + '.pickle', "rb" ))
        #oitemsim = original.calculateSimilarItems(org_prefs, n=50)

        
        print 'Calculating original ranking...'
        oranking = original.getRecommendedItems(org_prefs, oitemsim,user)

        print 'Calculating MAE for original...'
        original_MAE.append(getMAE(oranking,user, 'org'))

        
    #print original_MAE
    #print algorithm_MAE
    print sum(original_MAE)/len(original_MAE)
    
    pickle.dump(orgdetails, open("../rating_details/" + cid +"/orgdetails_" + cid, "wb"))