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

📄 model_multiway.m

📁 MOLMAP multiway toolbox是一个matlab集成工具箱
💻 M
字号:
function model = model_multiway(X,class,settings)

% model multiway data by means of MOLMAP approach
% model_multiway produces MOLMAP scores on multiway data
% 
% model = model_multiway(X,settings);
%
% input:
%   X           3way data [n x p x k], n samples, p variables, k variables
%   settings    setting structure
% 
% output:
%   model is a structure, with the following fields
%   model.net.W                 kohonen weights [size x size x k]
%   model.scal                  structure containing scaling parameters
%   model.label.label_sample    input-vector labels on the basis
%                               of original multiway samples
%   model.label.label_profile   input-vector labels on the basis of
%                               second mode variables
%   model.res.top_map           input-vector position in the kohonen map [n*p x 2]
%   model.res.score             MOLMAP score matrix (n x size*size), where
%                               size is the Kohonen map dimension defined in the settings 
% 
% important:
% - to define the settings structure type 'help som_settings'
% - data are always range scaled (inbetween 0 and 1) in order to
%   make them comparable with net weights
% - data are unfolded on the last mode, e.g. X(n,p,k) will give X2(n*p,k)
% 
% see the HTML HELP files (help.htm) for extensive explanations, details and examples
%
% The toolbox is freeware and may be used (but not modified) 
% if proper reference is given to the authors. Preferably refer to:
% D. Ballabio, V. Consonni, R. Todeschini
% Classification of multiway analytical data based on MOLMAP approach
% Analytica Chimica Acta, in press
% 
% version 1.0 - november 2007
% Davide Ballabio
% Milano Chemometrics and QSAR Research Group
% www.disat.unimib.it/chm

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

% arranges data and data scaling
[Xsca,scal,label_sample] = multiway_scaling(X,settings);

% calculates the map
net = som_net(Xsca,settings);

% projects the samples on the topmap
W_reshape = reshape(permute(net.W,[2 1 3]),[settings.nsize*settings.nsize size(Xsca,2)]);
for i = 1:size(Xsca,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

% molmap scores
score = multiway_score(Xsca,W_reshape,pos,label_sample,settings);

% build profile labels
label_profile = zeros(size(X,1)*size(X,2),1); 
for k=1:size(X,2); label_profile(k:size(X,2):end)=k; end;

% saves results
model.type = 'multiway';
model.net = net;
model.label.label_sample  = label_sample;
model.label.label_profile = label_profile;
model.scal = scal;
model.res.top_map = pos;
model.res.score = score;

⌨️ 快捷键说明

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