⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pred_kohonen.m

📁 this file is leverage algorithm written in matlab as m-file and tested in matlab.so anyone can ue th
💻 M
字号:
function pred = pred_kohonen(X,model)

% prediction of unknown samples with Kohonen maps
% pred_kohonen projects new samples by using a previuos model
% built by means of Kohonen maps (model_kohonen)
% 
% pred = pred_kohonen(X,model);
%
% input:
%   X           data [n x p], n samples, p variables
%   model       model structure built with model_kohonen
% 
% output:
%   pred is a structure, with the following fields
%   pred.top_map            sample position in the kohonen map [n x 2]
% 
% see the HTML HELP files (help.htm) for details and examples
%
% version 1.0 - may 2007
% Davide Ballabio
% Milano Chemometrics and QSAR Research Group
% www.disat.unimib.it/chm

% checks
errortype = kohonen_check(X,[],model,'pred');  
if ~strcmp(errortype,'none')
    disp(errortype)
    return
end

% data scaling
[Xsca,scal] = som_scaling(X,[],model);

% projects the samples on the topmap and assigns samples to classes
nsize = size(model.net.W,1);
W_reshape = reshape(permute(model.net.W,[2 1 3]),[nsize*nsize size(X,2)]);
for i = 1:size(X,1)
    x_in = Xsca(i,:);
    winner = som_winner(x_in,W_reshape);
    [pos(i,1),pos(i,2)] = som_which_neuron(winner,size(W_reshape,1));
end

% saves results
pred.type = 'kohonen';
pred.top_map = pos;

⌨️ 快捷键说明

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