반응형
pearson
-
유사도 구하기 (피어슨 상관계수)machine learning 2019. 3. 13. 19:16
피어슨 상관계수(Pearson correlation coefficient)Mathematical Expression유사도를 구하는 다른 방법중엔유클리디안, 코사인, 맨하튼 거리, 타니모토 계수등이 있다. 피어슨 상관계수는 두 변수의 선형관계를 파악하기 위해 사용하며 결과값 r은 (X와 Y가 함께 변하는 정도) / (X와 Y가 따로 변하는 정도) 이다.Code이 예제는 programming collective intelligence에 나오는 pearsson 함수입니다.def sim_pearson(prefs,p1,p2): # Get the list of mutually rated items si={} for item in prefs[p1]: if item in prefs[p2]: si[item]=1# if ..
반응형