def counter(list):
c_dict = {}
for i in list:
if i in c_dict:
c_dict[i] += 1
else:
c_dict[i] = 1
return c_dict
def entropy(x):
counts = counter(x) #每個變數出現的次數
prob = [i/len(x) for i in counts.values()] # 每個變數發生的機率
return -sum([i*math.log(i) for i in prob]) # 計算資訊熵
x = np.array([2,3,4,1,1,3,4,5,6,2,1,3,4,5,5,6,7,3,2,4,4,2])
print(entropy(x))
Python | 資訊熵 Information Entropy
相關文章
- 學習筆記《Information Entropy》筆記ORM
- 資訊熵概念隨筆——資訊熵、資訊的熵熵
- 熵、資訊量、資訊熵、交叉熵-個人小結熵
- 資訊熵(夏農熵)熵
- [機器學習]資訊&熵&資訊增益機器學習熵
- ML-熵、條件熵、資訊增益熵
- 資訊熵,交叉熵與KL散度熵
- 歸一化(softmax)、資訊熵、交叉熵熵
- 白話資訊熵熵
- 一文總結條件熵、交叉熵、相對熵、互資訊熵
- 資訊理論之從熵、驚奇到交叉熵、KL散度和互資訊熵
- Variation information(資訊差異指標)ORM指標
- 資訊熵相關知識總結熵
- 近似熵-樣本熵-多尺度熵熵
- tf中softmax_cross_entropy_with_logits與sparse_softmax_cross_entropy_with_logitsROSGit
- 熵、聯和熵與條件熵、交叉熵與相對熵是什麼呢?詳細解讀這裡有!熵
- 資訊化基礎的最小熵值的散點聚集熵
- 如何使用mysql 5.6 information schema定位事務鎖資訊MySqlORM
- 資訊系統規劃(Information System Planning, ISP)ORM
- 最大熵模型詳解與Python實現熵模型Python
- 理解"熵"熵
- MySQL information_schema庫下的表型別資訊彙總MySqlORM型別
- Information Retrieval(資訊檢索)筆記02:Preprocessing and Tolerant RetrievalORM筆記
- 【機器學習基礎】熵、KL散度、交叉熵機器學習熵
- 機器學習筆記之資訊熵、資訊增益和決策樹(ID3演算法)機器學習筆記熵演算法
- 簡單談談Cross Entropy LossROS
- 如何理解用資訊熵來表示最短的平均編碼長度熵
- 最大熵模型熵模型
- Uncertainy and informationAIORM
- 熵、交叉熵及似然函式的關係熵函式
- 交叉熵、相對熵及KL散度通俗理解熵
- 人以負熵為食——讀《資訊簡史》有點小感覺熵
- Server 層混雜資訊字典表 | 全方位認識 information_schemaServerORM
- Server層統計資訊字典表 | 全方位認識 information_schemaServerORM
- 潛在威脅資訊模型(PTIM)-Potential threats Information Modeling模型ORM
- SIS(Sales Information System)步驟2-維護自定義資訊結構ORM
- Consul的反熵熵
- [Information Security] What is WEPORM