?? rce.m
字號:
function D = RCE(train_features, train_targets, lambda_m, region)% Classify using the reduced coulomb energy algorithm% Inputs:% features - Train features% targets - Train targets% lambda_m - Maximum radius % region - Decision region vector: [-x x -y y number_of_points]%% Outputs% D - Decision sufraceepsilon = 1e-4;[Dim,Nf] = size(train_features);N = region(5);x = linspace (region(1),region(2),N);y = linspace (region(3),region(4),N);%Train the classifierW = train_features;lambda = zeros(1,Nf);for i = 1:Nf, dist = sqrt(sum((train_features - train_features(:,i) * ones(1,Nf)).^2)); [m, indices] = sort(dist); x_hat = find(train_targets(indices) ~= train_targets(i)); lambda(i) = min(dist(x_hat(1))-epsilon,lambda_m);end%Build the decision surface using the classifierD = zeros(N);for i = 1:N, for j = 1:N, dist = sqrt(sum((train_features - [x(i) y(j)]' * ones(1,Nf)).^2)); indices = find(dist < lambda); %The decision is a little different from DH&S, since there an ambiguous result can %Occure. Here we do not allow this. if isempty(indices), D(j,i) = rand(1) > .5; else D(j,i) = sum(train_targets(indices))/length(indices) > .5; end end if (i/50 == floor(i/50)), disp(['Finished ' num2str(i) ' lines out of ' num2str(N) ' lines.']); endend
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -