コード例 #1
0
ファイル: match_product.py プロジェクト: cyw3/PyCoder


#匹配物件
def transformPrefs(prefs):
    result={}
    for person in prefs:
        for item in prefs[person]:
            result.setdefault(item,{})

            #
            result[item][person]=prefs[person][item]
    return result


#test
import recommendations
import recommend_items
import similarity
movies=transformPrefs(recommendations.critics)
print similarity.topMatches(movies,'Lady in the Water')
#以影片推影评人
print recommend_items.getRecommendations(movies,'Just My Luck')
                    



#!/usr/bin/python

# Item based recommendation media system

import similarity

from logParser import mediaUserDict


print similarity.topMatches(mediaUserDict, '904968', 10, similarity.sim_distance)

print '-' * 50
print mediaUserDict
print '-' * 50

matriz = similarity.getArrayFromDict(mediaUserDict)
u, sigma, q = similarity.svd_components(matriz)

print 'u:\n%s\n' % u
print 'eigen value:\n%s\n' % sigma
print 'q transposta:\n%s\n' % q
print '*' * 50