How to reduce features using PCA and get good result on Pattern recognition ?
1 view (last 30 days)
Show older comments
Ali Zulfikaroglu on 4 Apr 2021
I have data 200x90. (rowsx columns)
My input has 200x88 and my target has 200x2 .
My data number (200 ) is less according to 88 features to get good accuracy on my neural network.
It should be more data to get good accuracy but I can't increase my data .
So I want to use PCA to reduce 88 features.
I loaded data200 and shared codes .
When I apply pca I got that error:
% Error using network/train (line 340)
% Inputs and targets have different numbers of samples.
% Error in deneme (line 50)
% [net,tr] = train(net,x,t);
Because it decreases my rows also. I want to keep my rows number (200) and just decrease column numbers.
I couldn't manage how to apply PCA in proper way.
% Solve a Pattern Recognition Problem with a Neural Network
% Script generated by Neural Pattern Recognition app
% Created 07-Feb-2021 15:50:44
% This script assumes these variables are defined:
% x - input data.
% t - target data.
% Choose a Training Function
% For a list of all training functions type: help nntrain
% 'trainlm' is usually fastest.
% 'trainbr' takes longer but may be better for challenging problems.
% 'trainscg' uses less memory. Suitable in low memory situations.
trainFcn = 'trainscg'; % Scaled conjugate gradient backpropagation.
% Create a Pattern Recognition Network
hiddenLayerSize = ;
net = patternnet(hiddenLayerSize, trainFcn);
% Setup 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,x,t);
% Test the Network
y = net(x);
e = gsubtract(t,y);
performance = perform(net,t,y)
tind = vec2ind(t);
yind = vec2ind(y);
percentErrors = sum(tind ~= yind)/numel(tind);
% View the Network
% Uncomment these lines to enable various plots.
Find more on Dimensionality Reduction and Feature Extraction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!