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

5 vues (au cours des 30 derniers jours)
julius bamwenda
julius bamwenda le 13 Août 2017
Commenté : shivasmic le 24 Juin 2019
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.

Réponse acceptée

Baptiste Ottino
Baptiste Ottino le 14 Août 2017
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 commentaires
julius bamwenda
julius bamwenda le 6 Sep 2017
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 le 24 Juin 2019
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!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by