Filter löschen
Filter löschen

How to create a training data from excel sheet to matlab?

3 Ansichten (letzte 30 Tage)
Nadiah Zainudin
Nadiah Zainudin am 10 Nov. 2017
Kommentiert: NICOLE MIN am 18 Mai 2020
close all; clear all; clc;
%load data & display data1= xlsread('DSN OFFSET.xlsx','R0'); disp(data1);
%filter data(divide training sets and test sets) X = data1(2,:); Y = data1(3,:);
%train = training data
What do i do next?

Antworten (1)

Shashika Munasingha
Shashika Munasingha am 3 Jun. 2019
Bearbeitet: Shashika Munasingha am 17 Mai 2020
There is a solution for this. I encountered similar problem and struggled for a while as there was no proper answer found in MatLab community. This is little bit lengthy and may not be the optimum solution, but hopefully this will solve some of your issues.
In my excel/csv, I have feature vector of length 7 and one output.
Here I used MatLab Deep Network Designer Toolbox (quite new toolbox) to generate the layer architecture and designed a nn setting input layer of dimension [7,1,1]. Design your network as you wish, but pay attention to the size of the inputs and outputs from each layer. They must be tallied with the data vectors in your excel/csv.
Import the NN model to MatLab workspace or you can create NN from scratch using code.
%% your layer architecture variable
net_layers
What I am going to highlight here is arranging our data such that it could be fed into our model.
%% importing data from csv file and separating them into target and input arrays %%
[~,~,data] = xlsread('temperature_feature_vector.csv');
data_mat = cell2mat(data);
target_array = categorical(data_mat(:,8));
input_array = data_mat(:,1:7);
%% reshaping input data such that it matches our model 2D ---> 4D
%% there are 53 input vectors in this example
x = reshape(input_array',[7,1,1,53]);
Now you have shaped your data accordingly. You are ready to train your network !!!
%define options for your network. you can change accordingly
options = trainingOptions('sgdm', ...
'ExecutionEnvironment','auto', ...
'InitialLearnRate',0.000003, ...
'LearnRateSchedule','piecewise', ...
'MaxEpochs',10, ...
'MiniBatchSize',1, ...
'SequenceLength','longest', ...
'Shuffle','never', ...
'Verbose',0, ...
'Plots','training-progress');
net = trainNetwork(x,target_array,net_layers,options);
With this method you can easily use deep nn models to train your data
Trick is in reshaping your data and defining of layer architecture accordingly.
  10 Kommentare
NICOLE MIN
NICOLE MIN am 18 Mai 2020
i got this issue, is matlab version incompatible?
NICOLE MIN
NICOLE MIN am 18 Mai 2020
firstly, ive copy the whole chuck of coding from the dic under read entire dataset, issue arises. secondly, ive tried replacing 'TEMPERATURE' TO 'X' same issue occur too. im not sure what is going on . i appreviacte very much if this issue can find a solution. thanks

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by