annotate toolboxes/FullBNT-1.0.7/bnt/examples/static/HME/hme_reg_plot.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function fh=hme_reg_plot(net, nodes_info, train_data, test_data)
Daniel@0 2 %
Daniel@0 3 % Use this function ONLY when the input dimension is 1
Daniel@0 4 % and the problem is a regression one.
Daniel@0 5 % We assume that each row of 'train_data' & 'test_data' is an example.
Daniel@0 6 %
Daniel@0 7 % ----------------------------------------------------------------------------------------------------
Daniel@0 8 % -> pierpaolo_b@hotmail.com or -> pampo@interfree.it
Daniel@0 9 % ----------------------------------------------------------------------------------------------------
Daniel@0 10
Daniel@0 11 fh=figure('Name','HME based regression', 'MenuBar', 'none', 'NumberTitle', 'off');
Daniel@0 12
Daniel@0 13 mn_x_train = round(min(train_data(:,1)));
Daniel@0 14 mx_x_train = round(max(train_data(:,1)));
Daniel@0 15 x_train = mn_x_train(1):0.01:mx_x_train(1);
Daniel@0 16 Z_train=fhme(net, nodes_info, x_train',size(x_train,2)); % forward propagation trougth the HME
Daniel@0 17
Daniel@0 18 if nargin==4,
Daniel@0 19 subplot(2,1,1);
Daniel@0 20 mn_x_test = round(min(test_data(:,1)));
Daniel@0 21 mx_x_test = round(max(test_data(:,1)));
Daniel@0 22 x_test = mn_x_test(1):0.01:mx_x_test(1);
Daniel@0 23 Z_test=fhme(net, nodes_info, x_test',size(x_test,2)); % forward propagation trougth the HME
Daniel@0 24 end
Daniel@0 25
Daniel@0 26 hold on;
Daniel@0 27 set(gca, 'Box', 'on');
Daniel@0 28 plot(x_train', Z_train, 'r');
Daniel@0 29 plot(train_data(:,1),train_data(:,2),'+k');
Daniel@0 30 title('Training set and prediction');
Daniel@0 31 hold off
Daniel@0 32
Daniel@0 33 if nargin==4,
Daniel@0 34 subplot(2,1,2);
Daniel@0 35 hold on;
Daniel@0 36 set(gca, 'Box', 'on');
Daniel@0 37 plot(x_train', Z_train, 'r');
Daniel@0 38 if size(test_data,2)==2,
Daniel@0 39 plot(test_data(:,1),test_data(:,2),'+k');
Daniel@0 40 end
Daniel@0 41 title('Test set and prediction');
Daniel@0 42 hold off
Daniel@0 43 end