how to turn matlab table into appropriate input for neural net package
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (2)
Faiz Gouri
il 1 Mar 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 Commenti
Salma Hassan
il 14 Gen 2018
Modificato: Salma Hassan
il 14 Gen 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 Commenti
Vedere anche
Categorie
Scopri di più su Sequence and Numeric Feature Data Workflows in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!