Step 5:
clear all;
clc;
close all;
net=feedforwardnet(10); %one hidden layer with 10 nodes
net.name = 'Wine Classification';
load wine_dataset; % load the wine data set
net = train(net,wineInputs,wineTargets); % train the network
mysample=wineInputs(:,27); %the 27th wine sample (out of 178)
y=net(mysample); % The network tests the 27th wine sample to determine which winery it came from.
bar(y);
set(gca,'xticklabel',{'Sonoma';'Bordeaux';'Newport'}); % Place labels along the x axis of the graph.
xlabel('Which Winery?');
Now
assume that we have an entirely new bottle of wine that comes from
one of the 3 wineries (not one of the 178 samples, but an entierly new
sample not used in training the network). Lets see how the network
classifies this wine.
The
wine is defined by its 13 attributes. To create this "new" wine,
I just took one of the 178 samples and randomly changed its numbers a
little:
newwine=[
10
1
2.5
15
117
1
4
0.8
2
2
1
3
850]; %13 attributes of a new wine.
Use the trained network to classify this wine:
y=net(newwine); % The network tests this new wine sample to determine which winery it came from.
bar(y);
set(gca,'xticklabel',{'Sonoma';'Bordeaux';'Newport'}); % Place labels along the x axis of the graph.
xlabel('Which Winery?');
Note:
Each time you run the program you may get a slightly different results
since the initial weights of the network connections are randomized
each time you run the program.