Info

This question is closed. Reopen it to edit or answer.

How to train data in Neural Network

1 view (last 30 days)
Turki
Turki on 13 Nov 2013
Closed: Walter Roberson on 15 Nov 2013
Hi all,
I am working on neural network to study cancer data, which has 680 record and labels. I just want to study the data and classify them to e classes. I've tried to write a code on matlab and I got result. But I don't know if it's correct or not.
So could you help me?
Thanks in advance.
close all, clear all, format compact
[num]= xlsread('Cdata2.xlsx');
[r,c] = size(num);
x = num(: ,1:c-1);
t = num(:,c);
inputs = x';
targets = t';
% Create a Pattern Recognition Network
hiddenLayerSize = 10;
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;
[trainInd,valInd,testInd] = dividerand(Q,trainRatio,valRatio,testRatio)
% Train the Network
[net,tr] = train(net,inputs,targets);
% Test the Network
outputs = net(inputs);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs);
perf = mse(net,targets,outputs);
% View the Network
view(net)
figure, plotregression(targets,outputs)
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
figure, plotconfusion(targets,outputs)
%figure, ploterrhist(errors)

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!