필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
julius bamwenda
julius bamwenda 2017년 8월 13일
댓글: shivasmic 2019년 6월 24일
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