making_recommendation
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| making_recommendation [2016/05/16 11:35] – created hkimscil | making_recommendation [2017/03/13 12:55] (current) – hkimscil | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | {{:class: | + | {{c: |
| + | {{0y100685.pdf|상관관계를 이용한 recommendation system 예}} | ||
| + | Python 실행 | ||
| + | <code py> | ||
| + | Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 | ||
| + | Type " | ||
| + | >>> | ||
| + | </ | ||
| + | 데이터 입력한다. 데이터는 critics라는 변수에 이름: | ||
| <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 27: | Line 34: | ||
| ' | ' | ||
| </ | </ | ||
| + | |||
| + | Eucledian distance | ||
| + | |||
| + | < | ||
| < | < | ||
| - | >> sqrt(pow(4.5-4,2)+pow(2-1,2)) | + | >> sqrt(pow(5-4, |
| - | 1.118033988749895 | + | 3.1622776601683795 |
| </ | </ | ||
| < | < | ||
| - | 0.4721359549995794 | + | 0.2402530733520421 |
| </ | </ | ||
| + | <WRAP clear /> | ||
| + | |||
| + | 아래는 persion1과 persion2 사이의 Distance를 구하는 definition | ||
| + | 위의 recommendations.py 에 추가. | ||
| <code py>from math import sqrt | <code py>from math import sqrt | ||
| Line 59: | Line 74: | ||
| similarity between two users. | similarity between two users. | ||
| - | < | + | |
| - | >>> | + | __for python 2.x__ |
| - | ... 'Lisa Rose',' | + | < |
| + | >>> | ||
| + | >>> | ||
| 0.148148148148 | 0.148148148148 | ||
| </ | </ | ||
| - | for python 3.xx | + | //for python 3.xx// |
| < | < | ||
| imp.reload(recommendations) | imp.reload(recommendations) | ||
| - | >>> | + | >>> |
| - | ... 'Lisa Rose',' | + | |
| 0.148148148148 | 0.148148148148 | ||
| </ | </ | ||
| Line 112: | Line 128: | ||
| < | < | ||
| - | >>> | + | >>> |
| - | ... 'Lisa Rose',' | + | >>> |
| + | >>> | ||
| 0.396059017191 | 0.396059017191 | ||
| </ | </ | ||
| Line 131: | Line 148: | ||
| < | < | ||
| - | >> recommendations.topMatches(recommendations.critics,' | + | >> recommendations.topMatches(recommendations.critics,' |
| - | [(0.99124070716192991, | + | [(0.99124070716192991, |
| - | (0.89340514744156474, | + | LaSalle' |
| </ | </ | ||
| - | |||
| - | |||
| ^ Critic | ^ Critic | ||
| Line 182: | Line 197: | ||
| < | < | ||
| - | >>> | + | >>> |
| - | [(3.3477895267131013, | + | [(3.3477895267131013, |
| - | Water' | + | >>> |
| - | >>> | + | [(3.5002478401415877, |
| - | ... similarity=recommendations.sim_distance) | + | |
| - | [(3.5002478401415877, | + | |
| - | Water' | + | |
| </ | </ | ||
| Line 348: | Line 360: | ||
| c+=1 | c+=1 | ||
| if c%100==0: print "%d / %d" % (c, | if c%100==0: print "%d / %d" % (c, | ||
| + | # for python3.4 윗줄을 아랫줄로 대체 | ||
| + | # if c%100==0: print ("%d / %d" % (c, | ||
| # Find the most similar items to this one | # Find the most similar items to this one | ||
| scores=topMatches(itemPrefs, | scores=topMatches(itemPrefs, | ||
making_recommendation.1463367922.txt.gz · Last modified: by hkimscil
