============================================================== FIND_SPECIFICITY: Find the specificity of a model. Code written by Katherine Smith, 2003 GENERAL [mean_specificity, std_specificity, all_specificities] = find_specificity(model, training_data, n_iterations, ref_points_vec, varargin) INPUT/S -model: The model for which specificity is evaluated. -training_data: The training data used to evalaute the specificity of that model. -n_iterations: ?The number of iterations used in the evaluation process? -ref_points_vec: ?Reference points? -varargin: ?Variance argument input? OUTPUT/S -mean_specificity: The mean specificity. -std_specificity: The standard deviation of specificities. -all_specificities: All the specificity values found. PENDING WORK -Resolve meaning of inputs and outputs. KNOWN BUG/S -None. COMMENT/S -Smith: Construct examples from model and measure the distance from the nearest example in training set -Full definition given by Rh. Davies. RELATED FUNCTION/S FIND_GENERALISABILITY ABOUT -Created: November 23rd, 2003 -Last update: Novermber 25th, 2003 -Revision: 0.0.2 -Author: R. S. Schestowitz, University of Manchester ==============================================================
0001 function [mean_specificity, std_specificity, all_specificities] = find_specificity(model, training_data, n_iterations, ref_points_vec, varargin) 0002 % ============================================================== 0003 % FIND_SPECIFICITY: Find the specificity of a model. 0004 % 0005 % Code written by Katherine Smith, 2003 0006 % 0007 % GENERAL 0008 % 0009 % [mean_specificity, std_specificity, all_specificities] = 0010 % find_specificity(model, training_data, n_iterations, 0011 % ref_points_vec, varargin) 0012 % 0013 % INPUT/S 0014 % 0015 % -model: 0016 % The model for which specificity is evaluated. 0017 % 0018 % -training_data: 0019 % The training data used to evalaute the specificity 0020 % of that model. 0021 % 0022 % -n_iterations: 0023 % ?The number of iterations used in the evaluation process? 0024 % 0025 % -ref_points_vec: 0026 % ?Reference points? 0027 % 0028 % -varargin: 0029 % ?Variance argument input? 0030 % 0031 % OUTPUT/S 0032 % 0033 % -mean_specificity: 0034 % The mean specificity. 0035 % 0036 % -std_specificity: 0037 % The standard deviation of specificities. 0038 % 0039 % -all_specificities: 0040 % All the specificity values found. 0041 % 0042 % PENDING WORK 0043 % 0044 % -Resolve meaning of inputs and outputs. 0045 % 0046 % KNOWN BUG/S 0047 % 0048 % -None. 0049 % 0050 % COMMENT/S 0051 % 0052 % -Smith: Construct examples from model and measure 0053 % the distance from the nearest example in training set 0054 % -Full definition given by Rh. Davies. 0055 % 0056 % RELATED FUNCTION/S 0057 % 0058 % FIND_GENERALISABILITY 0059 % 0060 % ABOUT 0061 % 0062 % -Created: November 23rd, 2003 0063 % -Last update: Novermber 25th, 2003 0064 % -Revision: 0.0.2 0065 % -Author: R. S. Schestowitz, University of Manchester 0066 % ============================================================== 0067 0068 args = u_packargs(varargin, 0,'n_modes', size(model.params,2)); 0069 0070 best_yet = ones(n_iterations,1)*size(training_data,1); %construct vector of as many ones as iternations and multiply these ones by the size of the training data 0071 stds = sqrt(model.variances); % get square roots of model variances 0072 stds = real(stds); % convert these to real numbers 0073 for i=1:n_iterations % for input number of iterations 0074 params = zeros(1,size(model.params,2)); 0075 % paramters set to 0, their size being the length of second bunch of model parameters 0076 invalid_params = 1; % set initially to invalid 0077 while(invalid_params) % and iterate while no validity proven 0078 params(1:args.n_modes) = randn(1,args.n_modes).*stds(1:args.n_modes); 0079 % for all modes, set them to a number in the range of their total number * the variance in the position of number of modes 0080 [example,points] = construct_model_example(params, model, ref_points_vec); 0081 % create a few examples given the parameters 0082 if(~is_invalid(points)) % if all our valid 0083 invalid_params = 0; % break out of loop 0084 end 0085 end 0086 0087 for j=1:size(training_data,2) 0088 distance = msd(example, training_data(:,j)); % get mean squred distance 0089 if(distance < best_yet(i)) % and try to find the closest yet 0090 best_yet(i) = distance; 0091 end 0092 end 0093 if(best_yet(i) > 10) 0094 disp('stop here'); 0095 end 0096 end 0097 mean_specificity = mean(best_yet); 0098 std_specificity = std(best_yet); 0099 all_specificities = best_yet;