- Represent each category as an integer
- Use 1-of-N encoding.
Invalid training data table
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hany Hussein
il 13 Dic 2020
Modificato: Alejandro Herrera
il 8 Ott 2021
Dear All,
I'm traing to train a network with numeric data, it reads a covid-19 Patients data such as Age, weight, gender and temprture, these data in csv format, here is my code
%loading file
filename = "Patient_cardio_COVID.csv";
tbl = readtable(filename,'TextType','String','PreserveVariableNames',true) ;
%Convert the labels for prediction to categorical using the convertvars function.
labelName = "active";
tbl = convertvars(tbl,labelName,'categorical');
categoricalInputNames = {'cardio','smoke', 'Body_Temprature'} ;
tbl = convertvars(tbl,categoricalInputNames,'categorical') ;
classNames = categories(tbl{:,labelName}) ;
%Split Data Set into Training and Validation Sets
%Partition the data set into training, validation, and test partitions. Set aside 15% of the data for validation, and 15% for testing.
numObservations = size(tbl,1) ;
%Determine the number of observations for each partition.
numObservationsTrain = floor(0.7*numObservations) ;
numObservationsValidation = floor(0.15*numObservations);
numObservationsTest = numObservations - numObservationsTrain - numObservationsValidation ;
%Create an array of random indices corresponding to the observations and partition it using the partition sizes
idx = randperm(numObservations);
idxTrain = idx(1:numObservationsTrain);
idxValidation = idx(numObservationsTrain+1:numObservationsTrain+numObservationsValidation);
idxTest = idx(numObservationsTrain+numObservationsValidation+1:end);
%Partition the table of data into training, validation, and testing partitions using the indices
tblTrain = tbl(idxTrain,:) ;
head (tblTrain)
tblValidation = tbl(idxValidation,:);
tblTest = tbl(idxTest,:);
%Define Network Architecture
numFeatures = size(tbl,2) - 1 ;
numClasses = numel(classNames) ;
layers = [
featureInputLayer(numFeatures,'Normalization', 'zscore')
fullyConnectedLayer(50)
batchNormalizationLayer
reluLayer
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer];
%Training Options
miniBatchSize = 16;
options = trainingOptions('adam', ...
'MiniBatchSize',miniBatchSize, ...
'Shuffle','every-epoch', ...
'ValidationData',tblValidation, ...
'Plots','training-progress', ...
'Verbose',false);
net = trainNetwork(tblTrain,labelName,layers,options);
at this stage I got this error messsage
"Invalid training data table. For networks with feature input, predictors must be numeric arrays, where each variable of
the table corresponds to one feature"
Any Advice
0 Commenti
Risposta accettata
Abhishek Gupta
il 16 Dic 2020
Hi,
As per my understanding, you are getting the "Invalid training data table" error while training a neural network. It seems like your input data isn't of the numeric type, instead is in the form of categories. Note that the ability to work with categorical variables is not available in Neural Network Toolbox and is supported with Statistics Toolbox.
The possible workaround for this would be to represent your categories as numeric values. For the same, you can follow any of the following approaches: -
Referring to the following link for more details: -
7 Commenti
Alejandro Herrera
il 8 Ott 2021
Modificato: Alejandro Herrera
il 8 Ott 2021
Hi Hany!
I have the same problem (Invalid training data table), can you teach me how to fix it?
Thank you
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Image Data Workflows in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!