how to create a target set for ANN classification???

3 次查看(过去 30 天)
i am trying to create a target set for my inputs to be used in classification with ANN but i have some challenges . i have 23 classes of images of which each class contains 100 images. feature extraction was done and i got a matrix of 2300*20736. how can i create a target set for my inputs.

采纳的回答

Baptiste Ottino
Baptiste Ottino 2017-8-14
Your target set must have one label for each sample, so it must contains 2300 elements. Here is an easy way to build one. Start by numbering your classes from 1 to 23. Make sure that your X Array is sorted by class, meaning all the samples from the first class, then all the samples from the second class, and so on. Then:
% Classes from 1 to 23
y = 1:23;
% 100 samples per class
y = repmat(y, 100, 1);
% Reshape to obtain a vector
y = reshape(y, 1, numel(y));
At this stage, you should have a 1-by-2300 vector with numeric class labels from 1 to 23. This is what you want if you use the Statistics and Machine Learning tToolbox.
Now, I suppose you intend to use the Neural Network Toolbox. In that case the syntax is a bit different: the class labels are in a 23-by-2300 matrix, each column being a sample, with the row corresponding to the class getting value '1' and the rest '0'. To build it from the previous syntax, type:
y = full(ind2vec(y));
Good luck!
  3 个评论
julius bamwenda
julius bamwenda 2017-9-6
Hi everyone, i have applied ANN and i have successfully got good results. so now i want to apply KNN classification method on the same data. as far as KNN is concerned, i have to create a training set, sample set and lastly the group set. ie: class=knnclassify(sample,training,group). so how can i create those sets? thanks in advance
shivasmic
shivasmic 2019-6-24
Baptiste ottino, thanx for the method, the method that you suggest for the comnstruction of target vector leads to the creation of matrix which has dimensions of 23 x 2300 but the input vector has dimension of 2300 x 20736.
Dont you think that the dimension of target vector should also be 2300 x 23.
I am asking this as I am also facing the same problem. Kindly clarify this as soon as possible!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by