基于Fisher准则线性分类器设计Word文档格式.docx
《基于Fisher准则线性分类器设计Word文档格式.docx》由会员分享,可在线阅读,更多相关《基于Fisher准则线性分类器设计Word文档格式.docx(14页珍藏版)》请在冰豆网上搜索。
都是d×
d维,得到的
也是一个d维的向量。
向量
就是使Fisher准则函数
达极大值的解,也就是按Fisher准则将d维X空间投影到一维Y空间的最佳投影方向,该向量
的各分量值是对原d维特征向量求加权和的权值。
以上讨论了线性判别函数加权向量W的确定方法,并讨论了使Fisher准则函数极大的d维向量
的计算方法,但是判别函数中的另一项
尚未确定,一般可采用以下几种方法确定
如
或者
或当
与
已知时可用
……
当W0确定之后,则可按以下规则分类,
使用Fisher准则方法确定最佳线性分界面的方法是一个著名的方法,尽管提出该方法的时间比较早,仍见有人使用。
五、实验内容
已知有两类数据
二者的概率已知
=0.6,
=0.4。
中数据点的坐标对应一一如下:
数据:
x1=
0.23311.52070.64990.77571.05241.1974
0.29080.25180.66820.56220.90230.1333
-0.54310.9407-0.21260.0507-0.08100.7315
0.33451.0650-0.02470.10430.31220.6655
0.58381.16531.26530.8137-0.33990.5152
0.7226-0.20150.4070-0.1717-1.0573-0.2099
x2=
2.33852.19461.67301.63651.78442.0155
2.06812.12132.47971.51181.96921.8340
1.87042.29481.77142.39391.56481.9329
2.20272.45681.75231.69912.48831.7259
2.04662.02262.37571.79872.08282.0798
1.94492.38012.23732.16141.92352.2604
x3=
0.53380.85141.08310.41641.11760.5536
0.60710.44390.49280.59011.09271.0756
1.00720.42720.43530.98690.48411.0992
1.02990.71271.01240.45760.85441.1275
0.77050.41291.00850.76760.84180.8784
0.97510.78400.41581.03150.75330.9548
数据点的对应的三维坐标为
1.40101.23012.08141.16551.37401.1829
1.76321.97392.41522.58902.84721.9539
1.25001.28641.26142.00712.18311.7909
1.33221.14661.70871.59202.93531.4664
2.93131.83491.83402.50962.71982.3148
2.03532.60301.23272.14651.56732.9414
1.02980.96110.91541.49010.82000.9399
1.14051.06780.80501.28891.46011.4334
0.70911.29421.37440.93871.22661.1833
0.87980.55920.51500.99830.91200.7126
1.28331.10291.26800.71401.24461.3392
1.18080.55031.47081.14350.76791.1288
0.62101.36560.54980.67080.89321.4342
0.95080.73240.57841.49431.09150.7644
1.21591.30491.14080.93980.61970.6603
1.39281.40840.69090.84000.53811.3729
0.77310.73191.34390.81420.95860.7379
0.75480.73930.67390.86511.36991.1458
数据的样本点分布如下图:
图1:
样本点分布图
六、实验要求
1)请把数据作为样本,根据Fisher选择投影方向
的原则,使原样本向量在该方向上的投影能兼顾类间分布尽可能分开,类内样本投影尽可能密集的要求,求出评价投影方向
的函数,并在图形表示出来。
并在实验报告中表示出来,并求使
取极大值的
。
用matlab完成Fisher线性分类器的设计,程序的语句要求有注释。
2)根据上述的结果并判断(1,1.5,0.6)(1.2,1.0,0.55),(2.0,0.9,0.68),(1.2,1.5,0.89),(0.23,2.33,1.43),属于哪个类别,并画出数据分类相应的结果图,要求画出其在
上的投影。
3)回答如下问题,分析一下
的比例因子对于Fisher判别函数没有影响的原因。
七、实验结果
1、源代码
x1=[0.23311.52070.64990.77571.05241.1974...
0.29080.25180.66820.56220.90230.1333...
-0.54310.9407-0.21260.0507-0.08100.7315...
0.33451.0650-0.02470.10430.31220.6655...
0.58381.16531.26530.8137-0.33990.5152...
0.7226-0.20150.4070-0.1717-1.0573-0.2099]'
;
y1=[2.33852.19461.67301.63651.78442.0155...
2.06812.12132.47971.51181.96921.8340...
1.87042.29481.77142.39391.56481.9329...
2.20272.45681.75231.69912.48831.7259...
2.04662.02262.37571.79872.08282.0798...
1.94492.38012.23732.16141.92352.2604]'
z1=[0.53380.85141.08310.41641.11760.5536...
0.60710.44390.49280.59011.09271.0756...
1.00720.42720.43530.98690.48411.0992...
1.02990.71271.01240.45760.85441.1275...
0.77050.41291.00850.76760.84180.8784...
0.97510.78400.41581.03150.75330.9548]'
%存储第一类点
x2=[1.40101.23012.08141.16551.37401.1829...
1.76321.97392.41522.58902.84721.9539...
1.25001.28641.26142.00712.18311.7909...
1.33221.14661.70871.59202.93531.4664...
2.93131.83491.83402.50962.71982.3148...
2.03532.60301.23272.14651.56732.9414]'
y2=[1.02980.96110.91541.49010.82000.9399...
1.14051.06780.80501.28891.46011.4334...
0.70911.29421.37440.93871.22661.1833...
0.87980.55920.51500.99830.91200.7126...
1.28331.10291.26800.71401.24461.3392...
1.18080.55031.47081.14350.76791.1288]'
z2=[0.62101.36560.54980.67080.89321.4342...
0.95080.73240.57841.49431.09150.7644...
1.21591.30491.14080.93980.61970.6603...
1.39281.40840.69090.84000.53811.3729...
0.77310.73191.34390.81420.95860.7379...
0.75480.73930.67390.86511.36991.1458]'
%存储第二类点
Pw1=0.6
Pw2=0.4
%求第一类点的均值向量m1
m1x=mean(x1(:
))%全部平均
m1y=mean(y1(:
m1z=mean(z1(:
m1=[m1x
m1y
m1z]
%求第二类点的均值向量m2
m2x=mean(x2(:
m2y=mean(y2(:
m2z=mean(z2(:
m2=[m2x
m2y
m2z]
%求第一类类内离散矩阵S1
S1=zeros(3,3)
fori=1:
36
S1=S1+([x1(i),y1(i),z1(i)]'
-m1)*([x1(i),y1(i),z1(i)]'
-m1)'
end
%求第二类类内离散矩阵S2
S2=zeros(3,3)
S2=S2+([x2(i),y2(i),z2(i)]'
-m2)*([x2(i),y2(i),z2(i)]'
-m2)'
%求总类内离散度矩阵Sw
Sw=S1+S2
%求向量W*
W=(inv(Sw))*(m1-m2)
%画出决策面
x=0:
.1:
2.5
y=0:
3
[X,Y]=meshgrid(x,y)
Z=(W
(1)*X+W
(2)*Y)/(-W(3))
mesh(X,Y,Z)
%保持
holdon
%透视决策面
hiddenoff
%求第一类样品的投影值均值
Y1=0
Y1=Y1+W'
*[x1(i),y1(i),z1(i)]'
M1=Y1/36
%求第二类样品的投影值均值
Y2=0
Y2=Y2+W'
*[x2(i),y2(i),z2(i)]'
M2=Y2/36
%选取阈值Y0
Y0=(M1+M2)/2+(log(Pw1)/log(Pw2))/70
%判定未知样品类别
X1=[1,1.5,0.6]'
ifW'
*X1>
Y0
disp('
点X1(1,1.5,0.6)属于第一类'
)
plot3(1,0.5,0.6,'
or'
else
点X1(1,1.5,0.6)属于第二类'
ob'
X2=[1.2,1.0,0.55]'
*X2>
点X2(1.2,1.0,0.55)属于第一类'
plot3(1.2,1.0,0.55,'
点X2(1.2,1.0,0.55)属于第二类'
X3=[2.0,0.9,0.68]'
*X3>
点X3(2.0,0.9,0.68)属于第一类'
plot3(2.0,0.9,0.68,'
点X3(2.0,0.9,0.68)属于第二类'
X4=[1.2,1.5,0.89]'
*X4>
点X4(1.2,1.5,0.89)属于第一类'
plot3(1.2,1.5,0.89,'
点X4(1.2,1.5,0.89)属于第二类'
X5=[0.23,2.33,1.43]'
*X5>
点X5(0.23,2.33,1.43)属于第一类'
plot3(0.23,2.33,1.43,'
点X5(0.23,2.33,1.43)属于第二类'
2、决策面
图2:
决策面(红色代表第一类,蓝色代表第二类)
3、参数
决策面向量
W=
-0.0798
0.2005
-0.0478
阈值
Y0=
0.1828
样本点分类
X1=
1.0000
1.5000
0.6000
点X1(1,1.5,0.6)属于第一类
X2=
1.2000
0.5500
点X2(1.2,1.0,0.55)属于第二类
X3=
2.0000
0.9000
0.6800
点X3(2.0,0.9,0.68)属于第二类
X4=
0.8900
点X4(1.2,1.5,0.89)属于第二类
X5=
0.2300
2.3300
1.4300
点X5(0.23,2.33,1.43)属于第一类
8、实验分析
1、比例因子
决策面向量W的比例因子并不影响判别函数。
分析如下:
阈值:
判别函数:
可以证明,Y0与WT有关,所以当改变WT时,判别函数两边同时改变,所以WT并不影响判别函数。
九、实验截图