LLE的算法的代码

更新时间:2023-07-04 23:14:19 阅读: 评论:0

LLE的算法的代码
% LLE ALGORITHM (using K nearest neighbors)society是什么意思
%
% [Y] = lle(X,K,dmax)
%
% X = data as D x N matrix (D = dimensionality, N = #points)
% K = number of neighbors
% dmax = max embedding dimensionality
% Y = embedding as dmax x N matrix
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%
carbfunction [Y] = lle(B,K,d)castiel
[D,N] = size(B);
fprintf(1,'LLE running on %d points in %d dimensions\n',N,D);
% STEP1: COMPUTE PAIRWISE DISTANCES & FIND NEIGHBORS
fprintf(1,'-->Finding %d nearest neighbours.\n',K);
b= sum(B.^2,1);
%if two point X=(x1,x2),Y=(y1,y2)
%than the distance between X and Y is sqtr(x1-y1)+sqtr(x2-y2)
distance = repmat(b,N,1)+repmat(b',1,N)-2*B'*B;
[sorted,index] = sort(distance);
neighborhood = index(2:(1+K),:);
% STEP2: SOLVE FOR RECONSTRUCTION WEIGHTS
fprintf(1,'-->Solving for reconstruction weights.\n');
if(K>D)
fprintf(1,' [note: K>D; regularization will be ud]\n');
tol=1e-3; % regularlizer in ca constrained fits are ill conditioned
el
实习医生格蕾第8季
tol=0;
end
w = zeros(K,N);
for ii=1:N
z = B(:,neighborhood(:,ii))-repmat(X(:,ii),1,K); % shift ith pt to origin
C = z'*z; % local covariance
C = C + eye(K,K)*tol*trace(C); % regularlization (K>D)
w(:,ii) = C\ones(K,1); % solve Cw=1endless story
w(:,ii) = w(:,ii)/sum(w(:,ii)); % enforce sum(w)=1
end
W=zeros(N,N);
关于爱情的英语文章
for j=1:N
for i=1:K
W(neighborhood(i,j),j)=w(i,j);socialcurity
end
end
% STEP 3: COMPUTE EMBEDDING FROM EIGENVECTS OF COST MA TRIX %M=(I-W)'*(I-W)
fprintf(1,'-->Computing embedding.\n');
% M=eye(N,N); % u a spar matrix with storage for 4KN nonzero elements
M = spar(1:N,1:N,ones(1,N),N,N,4*K*N);
for ii=1:N
ww = w(:,ii);
jj = neighborhood(:,ii);
M(ii,jj) = M(ii,jj) - ww';
M(jj,ii) = M(jj,ii) - ww;英语二级试题
M(jj,jj) = M(jj,jj) + ww*ww';
end
MFULL=full(M);
% CALCULA TION OF EMBEDDING
web rvices
options.disp = 0; options.isreal = 1; options.issym = 1;
m=input('Input the low demensional dimension plea:');
[Y,eigenvals] = eigs(M, m, 'lm',options);
%[Y,eigenvals] = jdqr(M, m);%change in using JQDR func
YY = Y'*sqrt(N); % bottom evect is [1,1,] with eval 0
fprintf(1,'Done.\n');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%
% other possible regularizers for K>D
惊喜英文怎么写%    C = C + tol*diag(diag(C)); % regularlization %    C = C + eye(K,K)*tol*trace(C)*K; % regularlization

本文发布于:2023-07-04 23:14:19,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/78/1078754.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:算法   爱情   代码   文章
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图