- 1、本文档共10页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
核主成分网络资料
核主成分程序:结果中要具体组成主成分的系数,核函数是多项式核函数!
the *getlist(int n=0){/*产生链表*/
the *p;
the *p1;
int i=0;
int j=0;
printf(请输入多项式的系数);
scanf(%d,j);
p=malloc(sizeof(the));
p1=p;
for(i=2;i=n;i++){
*p.i=j;
scanf(%d,j);
if(n!=i){
*p.next=malloc(sizeof(the));
p=*p.next;
}else{
*p.next=null;
}
}
return p;
}
int thesize(the *p){
int i=1;
while(*p.next!=null){
i++;
p=*p.next;
}
return i;
}
the* addthe(*p1,*p2){/*做加法*/
int size
if(thesize(*p1)thesize(*p2));
size=thesize(*p1);
else
size=thesize(*p2);
the *p;
p=getlist(size);
the *q;
int m,n,k,x,y;
for(k=0;ksize;k++){
m=thesize(*p1)-k;
n=thesize(*p2)-k;
if(m=0)
x=0;
else
x=getthevalue(m,p1).i;
if(n=0)
y=0;
else
y=getthevalue(n,p2).i;
q=getthevalue(k,p);
q.i=x+y;
}
}
the* getthevalue(int i;the *p){
the *p1=p;
int j=1;
while(ji){
p=*p.next;
j++;
}
return *p;
}
struct the{
the *next;
int i;
}
核主成份分析的MatLab实现
KPCA
function [eigvector, eigvalue,Y] = KPCA(X,r,opts)
%?% Kernel Principal Component Analysis ?% Written by Wei Yang?% [eigvector, eigvalue,Y] = KPCA(X,r,opts)% Input:?% X: d*N data matrix;Each column vector of X is a sample vector.?% r: Dimensionality of reduced space (default: d)?% opts:?? Struct value in Matlab. The fields in options that can be set:???????????????? ?%???????? KernelType? -? Choices are:%????????????????? Gaussian????? - exp{-gamma(|x-y|^2)}?%????????????????? Polynomial??? - (x*y)^d%????????????????? PolyPlus????? - (x*y+1)^d?%???????? gamma?????? -? parameter for Gaussian kernel%???????? d?????????? -? parameter for polynomial kernel?%?% Output:?% eigvector: N*r matrix;Each column is an embedding function, for a new?%??????????? data point (column vector) x,? y = eigvector*K(x,:)%??????????? will be the embedding result of x.%??????????? K(x,:) = [K(x1,x),K(x2,x),...K(xN,x)]% eigvalue: The sorted eigvalue of KPCA eigen-problem.?% Y?????? : Data matrix after the nonlinear transformif nargin1? error(Not enough input arguments.)?end? [d,N]=size(X);?if nargin2?? r=d;?end?%% Ensure r is not big
文档评论(0)