1、现代模式识别 - read(Modern pattern recognition - read)I carefully collated documents, documents from the networkI only collect and sort outIn case of errorPlease check it yourself!Modern pattern recognitionAlgorithm implementationThe principle of Parzen window method:In statistical decision makingClass pr
2、obability 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)To estimate P (x)It
3、s 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 as to converge to
4、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 satisfy the followi
5、ng 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., this method is im
6、plemented 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 is chosen to esti
7、mate 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:%-% Parzen window esti
8、mation% 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 = 1:N;Ran = randn (1
9、201);% 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 len = 0;First of all
10、 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) , x)Const double VN = 1;Double P = 0;List : iterator li;Realize the function in X /
11、 plug inFor (Li = m_listSample.begin (); Li = = m_listSample.end (); li+)P = WndFunc (VecOperator (x, *li, 1);Return P / m_listSample.size ();C+ implementation of ISODATA algorithmAlgorithm principle: slightlySpecific implementation: create a class classDefThe class contains the main arguments for:F
12、loat * Centre; / / the type of heart;Float dj_mean; / / the average distance in the class to class model of heartInt NJ; / / the number of within class model;Vector deta_j; / / intra class distance standard deviation vector;Vector modls; / / class model;Float detaj_max; / / the maximum standard devi
13、ation;Int pos_max; / / the maximum standard deviation component of the position;And processing functions for parameters:Void (cmp_centre); / / this type of Computing CenterVoid (cmp_meandis); / / the average distance calculation model in the heart of the classVoid (cmp_deta); / / calculate the stand
14、ard deviation of intra class distance vector;Program implementation timePatterns are obtained in matrix formClassify each pattern according to the algorithm principleAnd deal with all kinds ofSplitting and merging activities according to input (or default) parametersVerification resultVery good idea
15、 of the algorithmAnd got the right resultUsing data from a book exampleThe following correct results are obtainedInput mode matrixThe number of rows in the input matrix (that is, the number of modes): 8The number of columns in the input matrix (that is, the dimension of the model): 2Please enter fir
16、st modesZeroZeroPlease enter second modesOneOnePlease enter third modesTwoTwoPlease enter fourth modesFourTwo point sixPlease enter fifth modesFourThree point sevenPlease enter sixth modesFiveTwo point sixPlease enter seventh modesFiveThree point eightPlease enter eighth modesSixFour point six001122
17、42.643.752.653.864.6Do you want to define / redefine the value of the control parameter (y/n) n?First iterationFall into 2 categories:The first kind of mind is: 4.37304, 2.537500112242.643.752.653.864.6The second kind of mind is: 2.37696, 2.5375Do you want to define / redefine the value of the contr
18、ol parameter (y/n) n?Second iterationFall into 2 categories:The first kind of mind is: 4.8, 3.4642.643.752.653.864.6The second kind of mind is: 11001122Do you want to define / redefine the value of the control parameter (y/n) n?Third iterationFall into 2 categories:The first kind of mind is: 4.8, 3.
19、4642.643.752.653.864.6The second kind of mind is: 11001122Do you want to define / redefine the value of the control parameter (y/n) n?Fourth iterationFall into 2 categories:The first kind of mind is: 4.8, 3.4642.643.752.653.864.6The second kind of mind is: 11001122The iteration ends with Press any k
20、ey to continueSpecific procedures are as follows:#include #include #include #include #include #include Using namespace std;/ / input parameter definition -Float *X; / / matrix model;/int *centre; / / cluster center matrix, defined as c*dim effective number is Nc*dim; for Nc classList; / / categories
21、Vector: iterator, pointer;The function definition / awayVoid, inputPara ();Void, inputX ();Void, initiate ();Void, classAllot ();Void, cls_combine ();Void, cls_divide ();Void, showClass ();/ / class definition -Class classDefPublic:Float * Centre; / / the type of heart;Float dj_mean; / / the average
22、 distance in the class to class model of heartInt NJ; / / the number of within class model;Vector deta_j; / / intra class distance standard deviation vector;Vector modls; / / class model;Float detaj_max; / / the maximum standard deviation;Int pos_max; / / the maximum standard deviation component of
23、the position;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;Centre = new floatdim;For (I = 0; I detaj_max)detaj_max = mid_deta;pos_max =我;/ / -void main(int argc、argv char *
24、 )inputx();inputpara();initiate();对于(IP = 1;IP +)/ / step2to4;classallot();/ / 5如果(IP = i)seta_d = 0;/ /类合并step9to10;cls_combine();cout = 2C)|(IP % 2 = = 0) )cls_combine();其他的cls_divide();cout “第” IP “次迭代” endl;showclass();/ /检查是否要重新输入参数如果(IP)!=我)inputpara();cout endl “迭代结束” ;/ *无效 inputx()* 民 输入模式矩
25、阵 x暗淡* /无效 inputx()int,j;cout “输入模式矩阵” endl;cout “输入矩阵的行数(即模式的个数):” ;栏位;cout endl;cout “输入矩阵的列数(即模式的维数):” ;昏暗;cout endl;x =新浮动*;对于(i = 0;i ;i + +)cout “请输入第”我+ 1 “个模式” endl;新浮暗;对于(j = 0;j;昏暗;j + +)我;/ /显示矩阵;对于(i = 0;i ;i + +)cout endl;对于(j = 0;j;昏暗;j + +)cout x 我 J ” ;cout endl;/ *无效 inputpara()*输入控制参数并判断是否需要重设;* /无效 inputpara()