Tuesday, 20 January 2015

neural network in matlab 2014

Each row in Training belongs to one training data.
Each row in GroupTrain has the class of the corresponding training data.

In neural network, the model is trained using training data.

%classification using TreeBagger
model1 = TreeBagger(100,Training,GroupTrain,    'nprint',10);
disp(model1);

%How good the model is classifying the training data can tested by the following command

[tumortypeTrainPred, tumortypeTrainPredScores] = predict(model1,Training);

%to check the prediction of the model with just one instance that is 25th training data.
[tumortypeTrainPred, tumortypeTrainPredScores] = predict(model1,Training(25,:));
========================================================
%some demos in matlab 2014
edit classify_wine_demo
edit cancerdetectdemonnet
edit appcr1


One can watch the below video if using matlab 2010b using nntool
https://www.youtube.com/watch?v=2Z4959acjKs

and
http://in.mathworks.com/products/neural-network/features.html#data-fitting%2C-clustering%2C-and-pattern-recognition

In MATLAB 2014, one can make use of the following APPS found under APPS tab
neural net clustering
neural net fitting
neural net pattern recognition 
========================================================
Some more examples
========================================================
ldaClass = classify(Training(:,1:2),Training(:,1:2),GroupTrain);
N=size(GroupTrain,1);
bad = ~strcmp(ldaClass,GroupTrain);
ldaResubErr = sum(bad) / N
[ldaResubCM,grpOrder] = confusionmat(GroupTrain,ldaClass)

========================================================
clear all;
close all;
load('net.mat');
% Create a Pattern Recognition Network
hiddenLayerSize = 200;
net = patternnet(hiddenLayerSize);


% Set up Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;


% Train the Network
[net,tr] = train(net,inputs,targets);

% Test the Network
outputs = net(inputs);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs)


% View the Network
view(net);
%save the network
save(net);
%To do prediction, you can use sim(net, inputs)

%To Test the network
testX = inputs(:,tr.testInd);
testT = targets(:,tr.testInd);

testY = net(testX);
testIndices = vec2ind(testY);
=======================================

No comments:

Post a Comment