可分离性测量

机器算法验证 分类 支持向量机 线性模型 距离
2022-03-27 18:29:52

我有一个(二进制)分类问题,在将单个训练数据点(可以追溯到同一源)合并为聚合后,测试准确性(再次在单个数据点上)显着提高。通过合并,我的意思是添加和平均特征向量。使用 SVM 分类器/线性内核。(训练数据是有噪声的,因为它是半自动生成的)。

因此,有一种奇怪的情况是,使训练和测试数据更加“不同”(聚合与单个数据点)会提高性能。(此外,对于简单的线性回归,我猜将特征向量加在一起应该没有什么区别)。

我试图找出可能是什么原因。一种假设是,对于像 SVM 这样的大边距分类器来说,可分离性至关重要,并且通过聚合,由噪声引起的类之间的重叠较少。

最好有一个指标来指示“重叠”或“可分离性”的数量。这里的标准措施是什么?我计划对前两个 PCA 维度进行一些绘图,看看情况如何,但另外一些“可信数字”会很好。

1个回答

最常见的可分离性度量是基于类内分布重叠的程度(概率度量)。其中有几个,Jeffries-Matusita 距离、Bhattacharya 距离和转换后的散度。你可以很容易地用谷歌搜索一些描述。它们很容易实现。

还有一些基于最近邻居的行为。可分离性指数,主要看重叠的邻居的比例。假设边距是查看与同一类的最近邻(near-hit)和对立类的最近邻(near-miss)的距离。然后通过对此求和来创建一个度量。

然后你还有诸如类散布矩阵和集体熵之类的东西。

编辑

R中的概率可分离性度量

separability.measures <- function ( Vector.1 , Vector.2 ) {
# convert vectors to matrices in case they are not
  Matrix.1 <- as.matrix (Vector.1)
  Matrix.2 <- as.matrix (Vector.2)
# define means
mean.Matrix.1 <- mean ( Matrix.1 )
mean.Matrix.2 <- mean ( Matrix.2 )
# define difference of means
mean.difference <- mean.Matrix.1 - mean.Matrix.2
# define covariances for supplied matrices
cv.Matrix.1 <- cov ( Matrix.1 )
cv.Matrix.2 <- cov ( Matrix.2 )
# define the halfsum of cv's as "p"
p <- ( cv.Matrix.1 + cv.Matrix.2 ) / 2
# --%<------------------------------------------------------------------------
# calculate the Bhattacharryya index
bh.distance <- 0.125 *t ( mean.difference ) * p^ ( -1 ) * mean.difference +
0.5 * log (det ( p ) / sqrt (det ( cv.Matrix.1 ) * det ( cv.Matrix.2 )
)
)
# --%<------------------------------------------------------------------------
# calculate Jeffries-Matusita
# following formula is bound between 0 and 2.0
jm.distance <- 2 * ( 1 - exp ( -bh.distance ) )
# also found in the bibliography:
# jm.distance <- 1000 * sqrt (   2 * ( 1 - exp ( -bh.distance ) )   )
# the latter formula is bound between 0 and 1414.0
# --%<------------------------------------------------------------------------
# calculate the divergence
# trace (is the sum of the diagonal elements) of a square matrix
trace.of.matrix <- function ( SquareMatrix ) {
sum ( diag ( SquareMatrix ) ) }
# term 1
divergence.term.1 <- 1/2 * trace.of.matrix (( cv.Matrix.1 - cv.Matrix.2 ) * 
( cv.Matrix.2^ (-1) - cv.Matrix.1^ (-1) )
)
# term 2
divergence.term.2 <- 1/2 * trace.of.matrix (( cv.Matrix.1^ (-1) + cv.Matrix.2^ (-1) ) *
( mean.Matrix.1 - mean.Matrix.2 ) *
t ( mean.Matrix.1 - mean.Matrix.2 )
)
# divergence
divergence <- divergence.term.1 + divergence.term.2
# --%<------------------------------------------------------------------------
# and the transformed divergence
transformed.divergence  <- 2 * ( 1 - exp ( - ( divergence / 8 ) ) )
indices <- data.frame(
jm=jm.distance,bh=bh.distance,div=divergence,tdiv=transformed.divergence)
return(indices)
}

还有一些愚蠢的可重复的例子:

##### EXAMPLE 1
# two samples
sample.1 <- c (1362, 1411, 1457, 1735, 1621, 1621, 1791, 1863, 1863, 1838)
sample.2 <- c (1362, 1411, 1457, 10030, 1621, 1621, 1791, 1863, 1863, 1838)

# separability between these two samples
separability.measures ( sample.1 , sample.2 )

##### EXAMPLE 2
# parameters for a normal distibution
meen <- 0.2
sdevn <- 2
x <- seq(-20,20,length=5000)
# two samples from two normal distibutions
normal1 <- dnorm(x,mean=0,sd=1) # standard normal
normal2 <- dnorm(x,mean=meen, sd=sdevn) # normal with the parameters selected above

# separability between these two normal distibutions
separability.measures ( normal1 , normal2 )

请注意,这些度量一次仅适用于两个类和 1 个变量,并且有时会有一些假设(例如遵循正态分布的类),因此您应该在彻底使用它们之前阅读它们。但它们仍然可能满足您的需求。