opt_sphere.m

来自「wekaUT是 university texas austin 开发的基于wek」· M 代码 · 共 37 行

M
37
字号
function A = opt_sphere(X, S, D, maxiter)

% Preprocessing: First sphere the data
sphereMult = cov(X)^-0.5;
sphereX = X*sphereMult;

s = size(sphereX);
N = s(1);     % number of examples
d = s(2);     % dimensionality of examples            

A = eye(d,d)*0.1;
W = zeros(d,d);

for i = 1:N,
  for j = i+1:N,
    if S(i,j) == 1,
      d_ij = sphereX(i,:) - sphereX(j,:);
      W = W + d_ij'*d_ij;
    end;
  end;
end;     

w = unroll(W);
t = w' * unroll(A)/100;

[A, converge] = iter_projection_new2(sphereX, S, D, A, w, t, maxiter);
  
% Now unsphere the distance metric so that we get a version
% for the original, unsphered data.

unspheredA = inv(sphereMult)*A*inv(sphereMult);

A = unspheredA;



⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?