how to turn matlab table into appropriate input for neural net package
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a matlab table (T) with numeric and nominal variables. Other matlab documentation shows a "dummytable" function that turns the nominal variables in T into a table with nominal variables changed to dummy variables and leaves the numeric variables "as is". However, I cannot figure how to get this table into a form that can be accessed and read by the neural network input functions. Surely, there must be a straightforward way to do this. I just do not see it.
0 Kommentare
Antworten (2)
Faiz Gouri
am 1 Mär. 2017
You can refer the code below in order to convert table into Neural Network function input-
load('carsmall')
cars = table(MPG,Weight,Model_Year);
cars.Model_Year = categorical(cars.Model_Year);
categories(cars.Model_Year)
% now cars has Model_Year categorical(nominal) variable
% encode categorical variable
D = dummyvar(cars.Model_Year);
D = array2table(D);
D.Properties
% add new variable to cars
cars = [cars ,D];
cars.Model_Year =[];
% convert table to matrix as input to train function is R-by-Q matrix and
% U-by-Q matrix
inputs = table2array(cars(:,2:5))'; % R-by-Q
targets = cars.MPG'; % U-by-Q matrix
hiddenLayerSize = 10;
net = fitnet(hiddenLayerSize);
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
[net,tr] = train(net,inputs,targets);
0 Kommentare
Salma Hassan
am 14 Jan. 2018
Bearbeitet: Salma Hassan
am 14 Jan. 2018
imds=' D:\ ';
imds=imageDatastore(imds,'IncludeSubfolders',true,'FileExtensions','.png','LabelSource','foldernames'); [trainingimages,valDigitData]=splitEachLabel(imds,0.8,'randomize');
t=table(trainingimages.Files,trainingimages.Labels);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Sequence and Numeric Feature Data Workflows finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!