Home > . > prt_init_model.m

prt_init_model

PURPOSE ^

function to initialise the model data structure

SYNOPSIS ^

function [mid, PRT] = prt_init_model(PRT, in)

DESCRIPTION ^

 function to initialise the model data structure

 FORMAT: Two modes are possible: 
     mid = prt_init_model(PRT, in)
     [mid, PRT] = prt_init_model(PRT, in)

 USAGE 1:
 ------------------------------------------------------------------------
 function will return the id of a model or an error if it doesn't 
 exist in PRT.mat
 Input:
 ------
 in.model_name: name of the model (string)

 Output:
 -------
 mid : is the identifier for the model in PRT.mat

 USAGE 2: 
 -------------------------------------------------------------------------
 function will create the model in PRT.mat and overwrite it if it
 already exists.

 Input:
 ------
 in.model_name: name of the model to be created (string)
 in.use_kernel: use kernel or basis functions for this model (boolean)
 in.machine:    prediction machine to use for this model (struct)
 in.type:       'classification' or 'regression'

 Output:
 -------
 Populates the following fields in PRT.mat (copied from above):
 PRT.model(m).input.model_name 
 PRT.model(m).input.type 
 PRT.model(m).input.use_kernel 
 PRT.model(m).input.machine

 Note: this function does not write PRT.mat. That should be done by the
       calling function
__________________________________________________________________________
 Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [mid, PRT] = prt_init_model(PRT, in)
0002 % function to initialise the model data structure
0003 %
0004 % FORMAT: Two modes are possible:
0005 %     mid = prt_init_model(PRT, in)
0006 %     [mid, PRT] = prt_init_model(PRT, in)
0007 %
0008 % USAGE 1:
0009 % ------------------------------------------------------------------------
0010 % function will return the id of a model or an error if it doesn't
0011 % exist in PRT.mat
0012 % Input:
0013 % ------
0014 % in.model_name: name of the model (string)
0015 %
0016 % Output:
0017 % -------
0018 % mid : is the identifier for the model in PRT.mat
0019 %
0020 % USAGE 2:
0021 % -------------------------------------------------------------------------
0022 % function will create the model in PRT.mat and overwrite it if it
0023 % already exists.
0024 %
0025 % Input:
0026 % ------
0027 % in.model_name: name of the model to be created (string)
0028 % in.use_kernel: use kernel or basis functions for this model (boolean)
0029 % in.machine:    prediction machine to use for this model (struct)
0030 % in.type:       'classification' or 'regression'
0031 %
0032 % Output:
0033 % -------
0034 % Populates the following fields in PRT.mat (copied from above):
0035 % PRT.model(m).input.model_name
0036 % PRT.model(m).input.type
0037 % PRT.model(m).input.use_kernel
0038 % PRT.model(m).input.machine
0039 %
0040 % Note: this function does not write PRT.mat. That should be done by the
0041 %       calling function
0042 %__________________________________________________________________________
0043 % Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory
0044 
0045 % Written by A. Marquand
0046 % $Id: prt_init_model.m 176 2011-10-20 08:44:21Z amarquan $
0047 
0048 % find model index
0049 model_exists = false;
0050 if isfield(PRT,'model')
0051     if any(strcmpi(in.model_name,{PRT.model(:).model_name}))
0052         mid = find(strcmpi(in.model_name,{PRT.model(:).model_name}));
0053         model_exists = true;
0054     else
0055         mid = length(PRT.model)+1;
0056     end
0057 else
0058     mid = 1;
0059 end
0060 
0061 % do we want to create fields in PRT.mat?
0062 if nargout == 1
0063     if model_exists
0064         % just display message and exit (returning id)
0065         disp(['Model ''',in.model_name,''' found in PRT.mat.']);
0066     else
0067         error('prt_init_model:modelNotFoundinPRT',...
0068             ['Model ''',in.model_name,''' not found in PRT.mat.']);
0069     end
0070 else
0071     % initialise
0072     if model_exists
0073         warning('prt_init_model:modelAlreadyInPRT',['Model ''',in.model_name,...
0074             ''' already exists in PRT.mat. Overwriting...']);
0075     else
0076         disp(['Model ''',in.model_name,''' not found in PRT.mat. Creating...'])
0077     end
0078     % always overwrite the model
0079     PRT.model(mid).model_name       = in.model_name;
0080     PRT.model(mid).input.use_kernel = in.use_kernel;
0081     PRT.model(mid).input.type       = in.type;
0082     PRT.model(mid).input.machine    = in.machine;
0083 end
0084 
0085 end

Generated on Mon 03-Sep-2012 18:07:18 by m2html © 2005