


Run function to compute weights for linear kernel binary classifiers
FORMAT weights = prt_weights_bin_linkernel (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 [Nfeatures x 1]
__________________________________________________________________________
Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory

0001 function weights = prt_weights_bin_linkernel (d,args) 0002 % Run function to compute weights for linear kernel binary classifiers 0003 % FORMAT weights = prt_weights_bin_linkernel (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 [Nfeatures x 1] 0011 %__________________________________________________________________________ 0012 % Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory 0013 0014 % Written by J.Mourao-Miranda and M.J.Rosa 0015 % $Id: prt_weights_bin_linkernel.m 192 2011-10-24 10:57:19Z mjrosa $ 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 if ~isvector(d.coeffs) 0033 error('prt_weights_svm_bin:CoeffsnoVector',... 0034 'Error: ''coeffs'' must be a vector!'); 0035 else 0036 ncoeffs = length(d.coeffs); 0037 end 0038 else 0039 error('prt_weights_svm_bin:noCoeffsField',... 0040 ['Error: ''data'' struct must contain ''coeffs'' '... 0041 ' field!']); 0042 end 0043 end 0044 end 0045 0046 % create 1D image 0047 %-------------------------------------------------------------------------- 0048 img1d = zeros(size(d.datamat(1,:)),'single'); 0049 0050 % compute weigths 0051 for i=1:ncoeffs 0052 0053 tmp1 = single(d.datamat(i,:)); 0054 tmp2 = single(d.coeffs(i)); 0055 img1d = img1d + tmp1 * tmp2; 0056 0057 end 0058 0059 % weigths 0060 weights{1} = img1d;