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