Clear Filters
Clear Filters

Importing target_dataset from an excel file to a neural network toolbox for pattern recognition (nprtool)

12 views (last 30 days)
In the neural network toolbox in matlab (nnstart), i am using the Pattern recognition tool (nprtool); and i want to import a dataset from an excel file to the target field in the toolbox.
the problem is that i can import the input(matrix of size 1*50) easily, while i am not able to import the target (4 * 50) at all.
can someone please let me know whether there is a strict structure of the excel dataset, or is there a way to insert the target data.
thank you very much
  1 Comment
Charles Chilaka
Charles Chilaka on 21 Jan 2015
Edited: Charles Chilaka on 21 Jan 2015
I think the best way to go about this depending on the version of Matlab you are using is to first convert the excel file into .mat files, so that both the input and target files are in the Matlab workspace. Use the load command to load the two files at the Matlab prompt(one by one). After that, you create a network and train the network and every thing should be ok.. At times just going to the Matlab prompt and typing any of the commands does not give you the desired options of manipulation. Hope this helps

Sign in to comment.

Answers (2)

Charles Chilaka
Charles Chilaka on 16 Jan 2015
I had the same problem with my research and while waiting for any response, I decided to use the nftool instead of the nnstart. I first converted the excel files into .csv. The analysis are somehow different if you had succeeded in using nnstart. I am still trying to see how to load the excel files into the target using nnstart though.
  1 Comment
Charles Chilaka
Charles Chilaka on 21 Jan 2015
Edited: Charles Chilaka on 21 Jan 2015
I think the best way to go about this depending on the version of Matlab you are using is to first convert the excel file in .mat files, so that both the input and target files are in the Matlab workspace. Use the load command to load the two files at the Matlab prompt(one by one). After that, you create a network and train the network and every thing should be ok.. At times just going to the Matlab prompt and typing any of the commands does not give you the desired options of manipulation. Hope this helps

Sign in to comment.


Shashika Munasingha
Shashika Munasingha on 3 Jun 2019
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 as an image 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.

Community Treasure Hunt

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

Start Hunting!