Home > machines > prt_weights_gpclap.m

prt_weights_gpclap

PURPOSE ^

Run function to compute weights for linear multiclass classifiers

SYNOPSIS ^

function weights = prt_weights_gpclap (d,args)

DESCRIPTION ^

 Run function to compute weights for linear multiclass classifiers
 FORMAT weights = prt_weights_gpclap (d,args)
 Inputs:
       d              - data structure
           .datamat   - data matrix [Nfeatures x Nexamples]
           .coeffs    - coefficients vector [Nexamples x 1]
       args           - function arguments (can be empty)
 Output:
       weights        - vector with weights {Nclass}[Nfeatures x 1]
__________________________________________________________________________
 Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function weights = prt_weights_gpclap (d,args)
0002 % Run function to compute weights for linear multiclass classifiers
0003 % FORMAT weights = prt_weights_gpclap (d,args)
0004 % Inputs:
0005 %       d              - data structure
0006 %           .datamat   - data matrix [Nfeatures x Nexamples]
0007 %           .coeffs    - coefficients vector [Nexamples x 1]
0008 %       args           - function arguments (can be empty)
0009 % Output:
0010 %       weights        - vector with weights {Nclass}[Nfeatures x 1]
0011 %__________________________________________________________________________
0012 % Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory
0013 
0014 % Written by M.J.Rosa
0015 % $Id$
0016 
0017 SANITYCHECK = true; % turn off for speed
0018 
0019 % initial checks
0020 %--------------------------------------------------------------------------
0021 if SANITYCHECK == true
0022     if isempty(d)
0023         error('prt_weights_svm_bin:DataEmpty',...
0024             'Error: ''data'' cannot be empty!');
0025     else
0026         if ~isfield(d,'datamat')
0027             error('prt_weights_svm_bin:noDatamatField',...
0028                 ['Error: ''data'' struct must contain a ''datamat'' '...
0029                 ' field!']);
0030         end
0031         if isfield(d,'coeffs')
0032                 [ncoeffs nclass] = size(d.coeffs);
0033         else
0034             error('prt_weights_svm_bin:noCoeffsField',...
0035                 ['Error: ''data'' struct must contain ''coeffs'' '...
0036                 ' field!']);
0037         end
0038     end
0039 end
0040 weights=cell(nclass,1);
0041 for c = 1:nclass
0042     % create 1D image
0043     %----------------------------------------------------------------------
0044     img1d     = zeros(size(d.datamat(1,:)),'single');
0045     
0046     % compute weigths
0047     for i=1:ncoeffs
0048         
0049         tmp1 = single(d.datamat(i,:));
0050         tmp2 = single(d.coeffs(i,c));
0051         img1d = img1d + tmp1 * tmp2;
0052         
0053     end
0054     
0055     % weigths
0056     weights{c} = img1d;
0057     
0058 end

Generated on Tue 10-Feb-2015 18:16:33 by m2html © 2005