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
Best Answer