%clear 
%close 'all'
%clc
outpath = 'E:\Romanczyk\Classes\PR\Pres1\';

prwaitbar('off')


% Generate some data
data = gendatb( 400, 2 );
[ Test, Train ] = gendat( data, 0.5 );

% Train the classifires
w_nn = bpxnc( Train );
w_boost = adaboostc( Train, bpxnc, 10 );

% Classify both data subsets with both trained classifieres
nn_train_class = Train * w_nn;
boost_train_class = Train * w_boost;
nn_test_class = Test * w_nn;
boost_test_class = Test * w_boost;

save output

% Produce plots

maxValue = max( max( abs( data.data ) ) );



figure
scatterd( Train )
gridsize( 1 )
axis( [ -maxValue maxValue -maxValue maxValue] )
plotc( w_nn, 'k' )
plotc( w_boost, 'm:' )
h = gcf( );
saveas( h, [ outpath 'boostingTrain.eps' ], 'psc2' )
title( 'Training Data' )




figure
scatterd( Test )
gridsize( 1 )
axis( [ -maxValue maxValue -maxValue maxValue] )
plotc( w_nn, 'k' )
plotc( w_boost, 'm:' )
h = gcf( );
saveas( h, [ outpath 'boostingTest.eps' ], 'psc2' )
title( 'Testing Data' )


% produce error metrics
fprintf( 'Confusion Matrix for training with a neural net.\n' )
confmat( nn_train_class )
fprintf( 'Confusion Matrix for training with boosting.\n' )
confmat( boost_train_class )
fprintf( 'Confusion Matrix for testing with a neural net.\n' )
confmat( nn_test_class )
fprintf( 'Confusion Matrix for testing with boosting.\n' )
confmat( boost_test_class )

fprintf( 'Neural Net training error.\n' )
testc( nn_train_class )
fprintf( 'Boosting training error.\n' )
testc( boost_train_class )
fprintf( 'Neural Net testing error.\n' )
testc( nn_test_class )
fprintf( 'Boosting testing error.\n' )
testc( boost_test_class )



