日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

记录皮尔逊相关系数-相似性比较算法

發布時間:2024/4/14 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 记录皮尔逊相关系数-相似性比较算法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

皮爾森相關系數(Pearson correlation coefficient)也叫皮爾森積差相關系數(Pearson product-moment correlation coefficient),是用來反應兩個變量相似程度的統計量?;蛘哒f可以用來計算兩個向量的相似度(在基于向量空間模型的文本分類、用戶喜好推薦系統中都有應用)。

目前工作中由于比較學生對兩個考點的掌握情況的概率做統計來推薦合適的學習內容。

我太笨,讀書少,看不懂,只能記者,留著當作業。

?

公式是這樣的:

?

公式分解:

?

?

python 的實現:

# Input: 2 objects # Output: Pearson Correlation Score def pearson_correlation(object1, object2):values = range(len(object1))# Summation over all attributes for both objectssum_object1 = sum([float(object1[i]) for i in values]) sum_object2 = sum([float(object2[i]) for i in values])# Sum the squaressquare_sum1 = sum([pow(object1[i],2) for i in values])square_sum2 = sum([pow(object2[i],2) for i in values])# Add up the productsproduct = sum([object1[i]*object2[i] for i in values])#Calculate Pearson Correlation scorenumerator = product - (sum_object1*sum_object2/len(object1))denominator = ((square_sum1 - pow(sum_object1,2)/len(object1)) * (square_sum2 - pow(sum_object2,2)/len(object1))) ** 0.5# Can"t have division by 0if denominator == 0:return 0result = numerator/denominatorreturn result

等有時間寫個 C# 的算法。

?

內容來源參考:

http://mines.humanoriented.com/classes/2010/fall/csci568/portfolio_exports/sphilip/pear.html

https://segmentfault.com/q/1010000000094674

http://www.cnblogs.com/zhangchaoyang/articles/2631907.html

?

轉載于:https://www.cnblogs.com/easeyeah/p/pearson.html

總結

以上是生活随笔為你收集整理的记录皮尔逊相关系数-相似性比较算法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。