现代模式识别 - read(Modern pattern recognition - read).doc

上传人:rrsccc 文档编号:8792749 上传时间:2021-01-16 格式:DOC 页数:51 大小:71KB
返回 下载 相关 举报
现代模式识别 - read(Modern pattern recognition - read).doc_第1页
第1页 / 共51页
现代模式识别 - read(Modern pattern recognition - read).doc_第2页
第2页 / 共51页
现代模式识别 - read(Modern pattern recognition - read).doc_第3页
第3页 / 共51页
现代模式识别 - read(Modern pattern recognition - read).doc_第4页
第4页 / 共51页
现代模式识别 - read(Modern pattern recognition - read).doc_第5页
第5页 / 共51页
点击查看更多>>
资源描述

《现代模式识别 - read(Modern pattern recognition - read).doc》由会员分享,可在线阅读,更多相关《现代模式识别 - read(Modern pattern recognition - read).doc(51页珍藏版)》请在三一文库上搜索。

1、现代模式识别 - read(Modern pattern recognition - read)Data worth havingFrom the usual study, accumulation and summaryWhere there is a problem, there must be somePlease also criticize and correct me!Modern pattern recognitionAlgorithm implementationThe principle of Parzen window method:In statistical decis

2、ion makingClass probability density p (x / WI), class probability density P (WI) or posterior probability P (WI / x) need to be knownBut in practical applicationThe knowledge is often unknown or incompleteThis requires determination of samples based on samples from this classEstimated sequence: (1)T

3、o estimate P (x)Its with NVOfIn theoryTo hasten into P (x)It must have its volume V to be near zeroMeanwhile, let NInfinityThe Parzen window reduces the volume VN of the region sequence by a function of N with the increase of Nfor exampleAt this point, both / and N should be appropriately limitedSo

4、as to converge to P (x)In n-dimensional feature spaceWe take an n-dimensional hypercube regionIts edge length is hNIts volumethereforeN samples fall into the cubes number of samplesReplace the upper (1) formulaProbabilistic density estimation at x points is available:among(x) window functions that s

5、atisfy the following two conditions:In 1.In 2.Easy to knowCondition 1 guarantees non negativeCondition 2 guaranteeProcedures used in four window functions:1. square window function:2. normal window function3. exponential window function4. trigonometric window functionTwo, the concrete realization1.,

6、 this method is implemented in MATLABThe result is as followsH1 = 0.25, H1 = 1, H1 = 4N = 1N = 16H1 = 0.25, H1 = 1, H1 = 4N = 256N = H-infinityAs can be seen from the result of the graphThe larger the sample sizeThe more accurate the estimate isAt the same time, when the N is small, the window width

7、 is chosen to estimate the result properlyHave some influenceWhen N is smallThe window function has a great influence on the estimation resultsThe estimation result is far from the real distribution;When N increasesThe estimation results are close to the true distributionAttached matlab program:%-%

8、Parzen window estimation% PX is the mean zeroOne dimensional normal distribution with a variance of 1% creation function is chosen as normal window function 1/sqrt (2*pi) * exp (-u2/2)% window width hN = H1 / sqrt (N)%-Clear all;% preset parametersN = 1;H1 = 4;PX = zeros (1201);X= -2:0.02:2;For I =

9、1:N;Ran = randn (1201);% produces N normal distribution samplesFor J = 1:201;PX (J), =px (J) + (sqrt (N) / (h1*sqrt (2*pi) * exp (x (J) -ran (J) 2*N/ (-2*h1*h1);End;End;Semilogy (x, px/N);Axis (-4,4,0.001,10.0);2. implement with VCDouble CParzenWnd: WndFunc (vector, U)Vector : iterator, vi;Double le

10、n = 0;First of all to determine whether the correct dimension / /If (u.size () = = m_nDim)Exit (0);Return -1;The distance from the origin and /Using two normFor (VI = u.begin (); VI = = u.end (); vi+)Len = (*vi) * (*vi);If (sqrt (len) = 0.5)Return 1;ElseReturn 0;Double CParzenWnd: Probility (vector,

11、 x)Const double VN = 1;Double P = 0;列出;/ /实现在X处的内插函数为(李= m_listsample begin();李!= m_listsample。();李+ +)p = wndfunc(vecoperator(x,*李,1);P / m_listsample size()返回;ISODATA算法的C+实现算法原理:略具体实现:创建一个类classdef该类主要包含的参数为:浮*中心;/ /类心;浮dj_mean;/ /类中的模式到类心的平均距离int NJ;/ /类内模式的个数; deta_j矢量;/ /类内距离的标准差矢量;向量模型;/ /类中的模

12、式;浮detaj_max;/ /最大标准差;国际pos_max;/ /最大标准差分量的位置;以及对参数的处理函数:cmp_centre() /计算本类的中心无效;cmp_meandis() /计算类中模式到类心的平均距离无效;cmp_deta() /计算类内距离的标准差矢量无效;程序实现时模式以矩阵形式获得将各个模式按算法原理分类并处理各类并根据输入(或默认)参数进行分裂合并活动验证结果很好的体现了算法的思想并获得了正确的结果采用书上的例子的数据得出如下正确结果输入模式矩阵输入矩阵的行数(即模式的个数):8输入矩阵的列数(即模式的维数):21个模式请输入第零零2个模式请输入第一一3个模式请输入

13、第二二4个模式请输入第四二点六5个模式请输入第四三点七6个模式请输入第五二点六7个模式请输入第五三点八8个模式请输入第六四点六0 01 12 24 2.64 3.75 2.65 3.86 4.6是否需要定义/重新定义控制参数的值(Y / N)N1次迭代第2类分成:第类的类心为:4.37304 2.5375 10 01 12 24 2.64 3.75 2.65 3.86 4.6第类的类心为:2.37696 2.5375 2是否需要定义/重新定义控制参数的值(Y / N)N2次迭代第2类分成:第类的类心为:4.8 3.46 14 2.64 3.75 2.65 3.86 4.6第类的类心为:1 1

14、20 01 12 2是否需要定义/重新定义控制参数的值(Y / N)N3次迭代第2类分成:第类的类心为:4.8 3.46 14 2.64 3.75 2.65 3.86 4.6第类的类心为:1 1 20 01 12 2是否需要定义/重新定义控制参数的值(Y / N)N4次迭代第2类分成:第类的类心为:4.8 3.46 14 2.64 3.75 2.65 3.86 4.6第类的类心为:1 1 20 01 12 2迭代结束按任意键继续具体程序如下:#包括 iostream。”#包括#包括程序。”#包括字符串。”#包括数学。”#包括使用名称空间;/ /输入参数定义-浮* x;/模式矩阵;/ int *

15、 *中心;/ /聚类中心矩阵,定义成C *昏暗的有效个数为数控*暗淡;因为数控C;int2;int = 1;国际seta_n = 2;国际seta_s = 1;国际seta_d = 4;int1;int = i 4;/ /全局变量定义-int昏暗,民;/模式矩阵的维数和列数(即个数)浮d_mean;/ /各个模式到其类内中心的总体平均距离int IP;/ / 程序迭代次数;The vector classlist; / / 所分的类The vector : iterator pointer;/ / 函数定义 -Void inputpara ();Void inputx ();Void init

16、iate ();Void classallot ();Void CLS _ combine ();Void CLS _ divides ();Void showclass ();/ / 类定义 -Class classdefPublic:Float * Centre; / / 类心;Float DJ _ mean; / / 类中的模式到类心的平均距离Int NJ; / / 类内模式的个数;The vector deta _ J; / / 类内距离的标准差矢量;The vector modls; / / 类中的模式;Float detaj _ max; / / 最大标准差;Int POS _ m

17、ax; / / 最大标准差分量的位置;Classdef (int dim, float * x); classdef ();Void CMP _ Centre ();Void CMP _ meandis ();Void CMP _ deta ();/ / void CMP _ max ();Classdef: classdef (int dim, float * x)Int i;NJ = 0;The centre = new float dim;For (I = 0; I dim; I + +)* (centre + I) = * (x + 1);Classdef: classdef ()/

18、/ delete Centre;/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * void classdef: CMP _ Centre ()* 计算本类的中心* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /Void classdef: CMP _ Centre ()Int i, J;Float he;For (I = 0; I dim; I + +)He = 0;For (J = 0, J NJ; j +

19、+)He + = * (modls J + I).* (centre + I) = he / NJ;/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * void classdef: CMP _ deta ()* 计算各类中模式到类心的平均距离* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /Void classdef: CMP _ meandis ()Int i;Float he = 0;For (I = 0; I NJ

20、; I + +)He + = distance (modls i, Centre);DJ _ mean = he / NJ;/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * void classdef: CMP _ deta ()* 计算各类类内距离的标准差矢量* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /Void classdef: CMP _ deta ()Int i, J;Float mid _ deta.Detaj

21、 _ max = 0;POS _ max = 0;Deta _ j.clear ();For (I = 0; I dim; I + +)Mid _ deta = 0;For (J = 0, J detaj _ max)Detaj _ max = mid _ deta.POS _ max = I;/ / -Void main (int argc, char * argv )Inputx ();Inputpara ();Initiate ();It is (IP = 1; IP + +)/ / step2to4;Classallot ();/ / step5If (pi = = I)The arr

22、ow _ d = 0;/ / 类合并Step9to10;_ combine (CLS);Cout 第 PI 次迭代 endl;Showclass ();Break;If (NC = 2 * (c) | (IP% 2 = = 0)_ combine (CLS);Else_ divides (CLS);Cout 第 PI 次迭代 endl;Showclass ();/ / 检查是否要重新输入参数If (PI. = I)Inputpara ();Cout ENDL 迭代结束;/ * * * * * * * * * * * * * * * * * *Inputx (void *)* 输入模式矩阵 Di

23、m x num * * * * * * * * * * * * * * * * * * * /Inputx (void)Int i, J;Cout ENDL; 输入模式矩阵Cout num;Cout ENDL;Cout Dim;Cout ENDL;X = new float * num;For (i = 0; I num; I + +)Cout 请输入第 I + 1 个模式 ENDL;X I = new float Dim ;For (J = 0; J X I j./ / 显示矩阵;For (i = 0; I num; I + +)Cout ENDL;For (J = 0; J Dim; J

24、+ +)Cout x I j ;Cout ENDL;/ * * * * * * * * * * * * * * * * * *Inputpara (void *)* 输入控制参数并判断是否需要重设;* * * * * * * * * * * * * * * * * * * /Inputpara (void)Char a;Cout ;Cout ENDL;If (A = = and)Cout C;Cout ENDL;Cout NC;Cout ENDL;Cout Mushroom _ N;Cout ENDL;Cout Mushroom _ s;Cout ENDL;Cout Mushroom _ D;

25、Cout ENDL;Cout l;Cout ENDL;Cout I;Cout ENDL;Float distance (float * mod, float * Centre)Int i;Float DIS = 0;For (i = 0; I Dim; I + +)DIS = (+ (* - * (mod + i) + I (Centre) (mod) * * * i (+) - Centre + i);Return sqrt (DIS);/ * * * * * * * * * * * * * * * *Initiate (void *)* 取前nc个模式初始聚类中心* * * * * * *

26、 * * * * * * * * * /Initiate (void)Int i;For (i = 0; I CN; I + +)Classdef UNCCD (DIM, X I);Classlist.push _ Back (UNCCD);/ * * * * * * * * * * * * * * *Classallot (void *)* 将模式分类* 并计算分类后各类的参数* step2to4* * * * * * * * * * * * * * * /Classallot (void)Int i, J, pos;Float DIS;Float min;Bool change = tru

27、e;/ / 清除分到该类的模式 (以待分类 / 重新分类)If (Change)For (i = 0; I CN; I + +)ClassList R. Modls.clear ();ClassList.Nj I = 0;While (Change)Change = False;/ / 将各个模式分类 STEP (2)For (i = 0; I num; I + +)Min = distance (X I, classList.Centre 0);Pos = 0;For (J = J 1; NC; J + +)DIS = distance (X I, classList j.Centre);I

28、f (DIS min)Min = DIS;Pos = J;ClassList pos. Modls.push _ Back (X I);ClassList pos.Nj + +;/ / 由seta _ n判断合并 STEP (3)Classlist.begin Pointer = ();Int K = NC;For (i = 0; I K; I + +)如果(列表我。新泽西 seta_n)更改=真;列表删除(指针);数控-;指针+;/ /计算分类后的参数步骤(4)(6)对于(i = 0;i NC;+ +)cmp_centre()列表我;cmp_meandis()列表我;cmp_deta()列表

29、我;/ /计算总体平均距离步骤(4)d_mean = 0;对于(i = 0;i NC;+ +)d_mean + =列表我。新泽西*列表我。dj_mean;d_mean / =民;/ *无效cls_divide()*将符合条件的类分裂*第* /无效cls_divide()int i;中= Nc;布尔div = false;begin()指针=列表;对于(i = 0;i seta_s)&(列表我。dj_mean d_mean)和(列表我。新泽西2(seta_n + 1)|(NC = C / 2)/ /有类分裂发生=真;中+;classdef CLD(点心,列表我。中心);/ /新的类心ZJ*(cl

30、d.centre +列表我。pos_max)= 0.5 *(列表我。detaj_max);/ /加到类的容器中push_back(CLD)列表;/ /新的类心ZJ +*(列表我。中心+列表我。pos_max)+ = 0.5 *(列表我。detaj_max);数控机床;/ /如果没有分裂发生则转到STEP9如果(!DIV)cls_combine();/ *无效cls_combine();*将符合条件的类合并* step9to10* /无效cls_combine()int,j,q;int中;/ /中间变量;浮max_d = 0;/距离中的最大值浮min_d;int H,L / D的行和列的标号距离

31、矩阵;浮点数=新浮动*;中= Nc;/ /初始化距离矩阵,全部赋- 1值以利于后面的判断;对于(i = 0;i NC;+ +)d =新浮点数 NC ;对于(j = 0;j NC;j + +)我 = 1;/ /计算距离矩阵为(i = 0;i NC-1;i+)对于(j = i + 1;j max_d)max_d = D 我 J ;/ /取距离的最小值,并判断合并对于(q0;q l;Q + +)min_d = max_d;对于(i = 0;i NC;+ +)对于(j = i + 1;j 0)&(D 我 J seta_d)打破;/ /防止将要被合并的类以后被多次合并;对于(i = 0;i NC;+ +

32、)1;1;1;1;/ /合并,将H类作为合并后的新类对于(i = 0;i 模糊;i + +)*(列表 H 。中心+我)=(*(列表 H 。中心+我)*(列表 H 。台北)+(*(列表 H 。中心+我)*(列表 H 。台北)/(列表 H 。新泽西+列表1。台北);/ /将L中的类移到H中,如果(IP = i)为(i = 0;i 列表1。新泽西;i+)列表 H 。模型。push_back(列表1。模型我);列表 H 。新泽西+ +;/ /删除L类begin()指针=列表;指针+1;列表删除(指针);类的个数减少/ / 1中期;数控机床;/ *无效showclass()*显示类心及类的模式* /无效

33、showclass()int,p,q;int中;cout “分成”数控“类:“ endl;对于(i = 0;i NC;+ +)cout “第”我+ 1 “类的类心为:”;对于(q0;q 昏暗;Q + +)cout *(列表我。中心+ q)”;cout endl;中期=列表我。新泽西;对于(p0,p中,p)对于(q0;q 昏暗;Q + +)cout *(列表我。MODlS P + q)”;cout endl;H-K(Ho Kashyap)算法的MATLAB的实现算法原理:略具体实现:因本算法用到矩阵的运算所以采用MATLAB实现具体程序如下:函数h,c=(x,b,p,k)% -% H-K(Ho Kashap)算法H:解权矢量%C:程序循环迭代次数%X:训练模式的增广矩阵,要求已经符号规范化%B:余量矢量%P:增量校正步长%K:设定最大循环次数% -首先判断输入参数的正确性=

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1