分类目录:《机器学习中的数学》总目录
相关文章:
· 距离定义:基础知识
· 距离定义(一):欧几里得距离(Euclidean Distance)
· 距离定义(二):曼哈顿距离(Manhattan Distance)
· 距离定义(三):闵可夫斯基距离(Minkowski Distance)
· 距离定义(四):切比雪夫距离(Chebyshev Distance)
· 距离定义(五):标准化的欧几里得距离(Standardized Euclidean Distance)
· 距离定义(六):马氏距离(Mahalanobis Distance)
· 距离定义(七):兰氏距离(Lance and Williams Distance)/堪培拉距离(Canberra Distance)
· 距离定义(八):余弦距离(Cosine Distance)
· 距离定义(九):测地距离(Geodesic Distance)
· 距离定义(十): 布雷柯蒂斯距离(Bray Curtis Distance)
· 距离定义(十一):汉明距离(Hamming Distance)
· 距离定义(十二):编辑距离(Edit Distance,Levenshtein Distance)
· 距离定义(十三):杰卡德距离(Jaccard Distance)和杰卡德相似系数(Jaccard Similarity Coefficient)
· 距离定义(十四):Ochiia系数(Ochiia Coefficient)
· 距离定义(十五):Dice系数(Dice Coefficient)
· 距离定义(十六):豪斯多夫距离(Hausdorff Distance)
· 距离定义(十七):皮尔逊相关系数(Pearson Correlation)
· 距离定义(十八):卡方距离(Chi-square Measure)
· 距离定义(十九):交叉熵(Cross Entropy)
· 距离定义(二十):相对熵(Relative Entropy)/KL散度(Kullback-Leibler Divergence)
· 距离定义(二十一):JS散度(Jensen–Shannon Divergence)
· 距离定义(二十二):海林格距离(Hellinger Distance)
· 距离定义(二十三):α-散度(α-Divergence)
· 距离定义(二十四):F-散度(F-Divergence)
· 距离定义(二十五):布雷格曼散度(Bregman Divergence)
· 距离定义(二十六):Wasserstein距离(Wasserstei Distance)/EM距离(Earth-Mover Distance)
· 距离定义(二十七):巴氏距离(Bhattacharyya Distance)
· 距离定义(二十八):最大均值差异(Maximum Mean Discrepancy, MMD)
· 距离定义(二十九):点间互信息(Pointwise Mutual Information, PMI)
F-散度(F-Divergence)是KL散度的一个推广:
D
F
(
p
∣
∣
q
)
=
∫
q
(
x
)
f
(
p
(
x
)
q
(
x
)
)
D_F(p||q)=\int q(x)f(\frac{p(x)}{q(x)})
DF(p∣∣q)=∫q(x)f(q(x)p(x))
其中,函数 f ( x ) f(x) f(x)需要满足下列2个性质:
若 f ( x ) = x log x f(x)=x\log{x} f(x)=xlogx,则F-散度退化为KL散度;若 f ( x ) = − log x f(x)=-\log{x} f(x)=−logx,则F-散度退化为reverse KL散度。甚至,当 f ( x ) f(x) f(x)取某些值时,还可以表达 α \alpha α-散度。下面的表格给出了F-散度的一些特例:
散度(Divergence) | 对应的 f ( x ) f(x) f(x) |
---|---|
KL散度 | x log x x\log{x} xlogx |
reverse KL散度 | − log x -\log{x} −logx |
海林格距离 | ( x − 1 ) 2 (\sqrt{x}-1)^2 (x−1)2 |
卡方距离 | ( t − 1 ) 2 (t-1)^2 (t−1)2 |
α \alpha α-散度 | 4 1 − α 2 ( 1 − x 1 + α 2 ) ( α ≠ ± 1 ) \frac{4}{1-\alpha^2}(1-x^{\frac{1+\alpha}{2}})\quad(\alpha\neq\pm1) 1−α24(1−x21+α)(α=±1) |
KL散度 | x log x x\log{x} xlogx |
KL散度 | x log x x\log{x} xlogx |
下面我们来看一下海林格距离的Python实现:
def f(t):
return t*np.log(t)
def F_Divergence(p, q):
import numpy as np
p = np.array(p)
q = np.array(q)
M = (p + q)/2
return np.sum(q*f(p/q))