User Tools

Site Tools


making_recommendation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
making_recommendation [2016/05/17 06:24] hkimscilmaking_recommendation [2017/03/13 12:55] (current) hkimscil
Line 1: Line 1:
-{{:class:swap:recommendations_toby.pdf|Reading material}}+{{c:swap:recommendations_toby.pdf|Reading material}} 
 +{{0y100685.pdf|상관관계를 이용한 recommendation system 예}}
 Python 실행 Python 실행
 <code py>c:\code\collective\chapter2> python <code py>c:\code\collective\chapter2> python
Line 6: Line 7:
 >>> >>>
 </code> </code>
-데이터 입력한다. 데이터는 critics라는 변수에 이름:영화:점수의 nested 형식으로 기록된다.+데이터 입력한다. 데이터는 critics라는 변수에 이름:영화:점수의 nested 형식으로 기록된다. recommendations.py에 저장
 <code py># A dictionary of movie critics and their ratings of a small <code py># A dictionary of movie critics and their ratings of a small
 # set of movies # set of movies
Line 49: Line 50:
 <WRAP clear /> <WRAP clear />
  
 +아래는 persion1과 persion2 사이의 Distance를 구하는 definition 
 +위의 recommendations.py 에 추가.
 <code py>from math import sqrt <code py>from math import sqrt
  
Line 71: Line 74:
  
 similarity between two users. similarity between two users.
-<code>>>> reload(recommendations) + 
->>> recommendations.sim_distance(recommendations.critics, +__for python 2.x__ 
-... 'Lisa Rose','Gene Seymour')+<code>>>> import(recommendations)  
 +>>>reload(recommendations) 
 +>>> recommendations.sim_distance(recommendations.critics,'Lisa Rose','Gene Seymour')
 0.148148148148 0.148148148148
 </code> </code>
  
-for python 3.xx+//for python 3.xx//
 <code>>>> import recommendations <code>>>> import recommendations
 imp.reload(recommendations) imp.reload(recommendations)
->>> recommendations.sim_distance(recommendations.critics, +>>> recommendations.sim_distance(recommendations.critics,'Lisa Rose','Gene Seymour')
-... 'Lisa Rose','Gene Seymour')+
 0.148148148148 0.148148148148
 </code> </code>
Line 124: Line 128:
  
 <code>>>> reload(recommendations) <code>>>> reload(recommendations)
->>> print recommendations.sim_pearson(recommendations.critics, +>>> print recommendations.sim_pearson(recommendations.critics,'Lisa Rose','Gene Seymour') 
-... 'Lisa Rose','Gene Seymour')+>>> # for python 3.4 아랫줄로 대체해서 사용할 것 
 +>>> print (recommendations.sim_pearson(recommendations.critics,'Lisa Rose','Gene Seymour'))
 0.396059017191 0.396059017191
 </code> </code>
Line 143: Line 148:
  
 <code>>> reload(recommendations) <code>>> reload(recommendations)
->> recommendations.topMatches(recommendations.critics,'Toby',n=3) +>> recommendations.topMatches(recommendations.critics,'Toby',n=3)  
-[(0.99124070716192991, 'Lisa Rose'), (0.92447345164190486, 'Mick LaSalle'), +[(0.99124070716192991, 'Lisa Rose'), (0.92447345164190486, 'Mick  
-(0.89340514744156474, 'Claudia Puig')]+LaSalle'), (0.89340514744156474, 'Claudia Puig')]
 </code> </code>
- 
- 
  
 ^ Critic  ^ Similarity  ^ Night  ^ S.xNight  ^ Lady  ^ S.xLady  ^ Luck  ^ S.xLuck  ^ ^ Critic  ^ Similarity  ^ Night  ^ S.xNight  ^ Lady  ^ S.xLady  ^ Luck  ^ S.xLuck  ^
Line 194: Line 197:
  
 <code>>>> reload(recommendations) <code>>>> reload(recommendations)
->>> recommendations.getRecommendations(recommendations.critics,'Toby'+>>> recommendations.getRecommendations(recommendations.critics,'Toby')  
-[(3.3477895267131013, 'The Night Listener'), (2.8325499182641614, 'Lady in the +[(3.3477895267131013, 'The Night Listener'), (2.8325499182641614, 'Lady in the Water'), (2.5309807037655645, 'Just My Luck')] 
-Water'), (2.5309807037655645, 'Just My Luck')] +>>> recommendations.getRecommendations(recommendations.critics,'Toby', similarity=recommendations.sim_distance)  
->>> recommendations.getRecommendations(recommendations.critics,'Toby', +[(3.5002478401415877, 'The Night Listener'), (2.7561242939959363, 'Lady in the Water'), (2.4619884860743739, 'Just My Luck')] 
-... similarity=recommendations.sim_distance) +
-[(3.5002478401415877, 'The Night Listener'), (2.7561242939959363, 'Lady in the +
-Water'), (2.4619884860743739, 'Just My Luck')]+
 </code> </code>
  
Line 360: Line 360:
     c+=1     c+=1
     if c%100==0: print "%d / %d" % (c,len(itemPrefs))     if c%100==0: print "%d / %d" % (c,len(itemPrefs))
 +    # for python3.4 윗줄을 아랫줄로 대체
 +    # if c%100==0: print ("%d / %d" % (c,len(itemPrefs)))
     # Find the most similar items to this one     # Find the most similar items to this one
     scores=topMatches(itemPrefs,item,n=n,similarity=sim_distance)     scores=topMatches(itemPrefs,item,n=n,similarity=sim_distance)
making_recommendation.1463435652.txt.gz · Last modified: 2016/05/17 06:24 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki