chisquare特征选择算法:
通过计算各个特征的卡方值,进行排序后得到。
步骤如下: 1. 假设该特征与目标特征无关。 2. 计算卡方值,若卡方值较小,则相关性较小; 若较大,则相关性较大。
每个特征的卡方值计算应如下:
X^2 = ∑ ((YA - YB)^ 2 / YB)
其中,YA是每个样本中,YA的实际值,而YB为理想值,即假设无关成立时,理想的值。
由于假设该特征与目标特征无关,则应当在该特征的范围上,目标特征值均匀分布。
例如:
假设X 有三种分类,XA,XB,XC. Y 有两种分类, Y1,Y2
则对于卡方值计算有
Y1 | Y2 | 合计 | |
XA | a | b | a+b |
XB | c | d | c+d |
XC | e | f | e+f |
合计 | a+c+e | b+d+f |
由于X属性与Y属性无关, 则有, (a+b) * (a+c+