-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpmodelvars.m
71 lines (56 loc) · 1.93 KB
/
gpmodelvars.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function hitvec=gpmodelvars(gp,ind)
%GPMODELVARS Displays the frequency of the input variables present in the
%specified individual in the population and returns the corresponding
%frequency vector.
%
% HITVEC=GPMODELVARS(GP,IND) operates on the population member with
% population index IND in the GPTIPS datastructure GP.
%
% HITVEC=GPMODELVARS(GP,''BEST'') operates on the best individual of the
% run.
%
% HITVEC=GPMODELVARS(GP,''VALBEST'') operates on the individual that
% performed best on the validation data (if it exists).
%
% (c) Dominic Searson 2009
%
% v1.0
if nargin<2
disp('Usage is GPMODELVARS(GP,IND) where IND is the population index of the selected individual.');
disp('or GPMODELVARS(GP,''best'') to run the best individual in the population.');
return;
end
%get a specified individual from the population and
% scan it for input variables
if isnumeric(ind)
model=gp.pop{ind};
title_str=['gpmodelvars: input frequency in individual with index: ' int2str(ind)];
elseif ischar(ind) && strcmpi(ind,'best')
model=gp.results.best.individual;
title_str='gpmodelvars: input frequency in best individual.';
elseif ischar(ind) && strcmpi(ind,'valbest')
% check that validation data is present
if (~isfield(gp.userdata,'xval')) || (~isfield(gp.userdata,'yval')) || ...
isempty(gp.userdata.xval) || isempty(gp.userdata.yval)
disp('No validation data was found. Try gpmodelvars(gp,''best'') instead.');
return;
end
model=gp.results.valbest.individual;
title_str='gpmodelvars: input frequency in best validation individual.';
else
error('Illegal argument');
end
%perform scan
numx=gp.nodes.inputs.num_inp;
hitvec=scangenes(model,numx);
% plot results as barchart
h=figure;
set(h,'name','gpmodelvars','numbertitle','off');
a=gca;
bar(a,hitvec);
axis tight;
xlabel('Input number');
ylabel('Input frequency');
title(title_str);
grid on;
hitvec=hitvec';