Deep Learning ANN Classification Model

9 次查看(过去 30 天)
Hi,
I am trying to develop a pattern recognition classification ANN model for 10 different classes using 11 inputs. The model runs but the performance is poor (less than 20%). I want to try to a deep learning technique. However, all the examples are for image-based classification. My problem is numerical-based (no image). Is there a way to do a deep learning pattern-based classification model in MATLAB? Is there an example on how to do that?

采纳的回答

Cris LaPierre
Cris LaPierre 2023-12-5
编辑:Cris LaPierre 2023-12-5
Absolutely. Here is a page showing multiple examples, none of which are images: https://www.mathworks.com/help/deeplearning/gs/pattern-recognition-with-a-shallow-neural-network.html
These are all shallow networks. You can turn a shallow network into a deep network by adding more layers.
I would suggest using the Neural Network Pattern Recognition App to create a network, and then export the code. You can then manually expand that. Here's an example I built up based on the Iris data set example in the app (4 inputs, 3 outputs)
% Solve a Pattern Recognition Problem with a Neural Network
% Script generated by Neural Pattern Recognition app
% Created 05-Dec-2023 10:55:42
%
% This script assumes these variables are defined:
%
% irisInputs - input data.
% irisTargets - target data.
x = irisInputs;
t = irisTargets;
% 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.
This is the section of code that creates the layers. It is a shallow network because there is only 1 hidden layer
% Create a Pattern Recognition Network
hiddenLayerSize = 10;
net = patternnet(hiddenLayerSize, trainFcn);
You can turn this into a deep learning network by adding more hidden layers. For example, this code would create a 3-layer network.
% Three hidden layer NN
hiddenLayerSize1 = 10;
hiddenLayerSize2 = 20;
hiddenLayerSize3 = 15;
net = patternnet([hiddenLayerSize1 hiddenLayerSize2 hiddenLayerSize3], 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
view(net)
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, ploterrhist(e)
%figure, plotconfusion(t,y)
%figure, plotroc(t,y)
  7 个评论
Cris LaPierre
Cris LaPierre 2023-12-6
编辑:Cris LaPierre 2023-12-6
Not knowing anything about your data, I think you may need to look into feature engineering. Three of your inputs are highly correlated, meaning they aren't adding anything new to the model. However, even after eliminating them, I get similar results. To me, this means there is not enough difference in your inputs to generate an accurate model.
It = readmatrix("InputsMethod1.xlsx");
Ot = readmatrix("Outputs1.xlsx");
xnames = "input" + (1:4);
x = It';
t = Ot';
% turn t into vector of 'class labels'
f = max((0.1:0.1:1)' .* t);
% Normalize data
[x,ps]=mapminmax(x,0,1);
figure
plot([x;f])
% Inputs 1, 2 and 3 are highly correlated
figure
gplotmatrix(It,[],f,[],[],[],[],[],xnames)
% Detemine which features have the highest predictive power
[idx,scores] = fscmrmr(It,f')
idx = 1×4
1 4 2 3
scores = 1×4
0.0397 0.0034 0.0031 0.0205
bar(scores(idx))
xlabel('Predictor rank')
ylabel('Predictor importance score')
xticklabels(xnames(idx));
Here are the results I get with a shallow network for the 2 top features.

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by