Knn classification on a dataset

22 次查看(过去 30 天)
Hi i have this dataset and i want knn classification for this and also find accuracy of performance of this classification and showing the number of wrong and true classifications with confusion matrix. Any one can help me with this .please.
  3 个评论
Mary Gh
Mary Gh 2020-12-31
Well they are A to I classes with 2 train datas (two lables,)and one test data
Mary Gh
Mary Gh 2020-12-31
Actually i dont think they represent anything it didnt say in question

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2020-12-31
So one is to train, the other "training" one is for validation (run it through and see how accurate the predictions are compared to the known values), and the third one is a test set (which you do not know the correct answers for).
I have attached a KNN demo. See if you can adapt that to your homework problem. If not, come back for more hints.
  21 个评论
merlin toche
merlin toche 2023-1-6
thank you sir! i'm very happy.
please, sir I have other questions via my profile as you said concern your previous answers.
best regards
Image Analyst
Image Analyst 2023-1-6
@merlin toche Not sure what that means, but in your profile, it says you've submitted only one question, and one answer. If you have asked other questions in the comments to someone else's question, then that won't show up. That's why it's best to ask your own questions in your own thread rather than try to post the questions in someone else's thread, like here in @Mary Gh's thread. She'll get emails every time there is activity in this thread.

请先登录,再进行评论。

更多回答(1 个)

merlin toche
merlin toche 2022-12-9
thank you sir for all you do for me. well explained and well understood. excuse me for continuing to bother you, please, I'm still learning machine learning, and you are a good teacher for me. I have two concerns sir:
My first question is sir after partitioning my data (I did it using cvpartion mydata1=rand(150.4);
% cross-variation (Train: 80%, Test: 20%)
cv=cvpartition(size(mydata1,1),'holdout',0.2);
idx=cv.test;
% sparse training and test data
mydata1_train=mydata1(~idx,:);
mydata1_test=mydata1(idx,:);
% data evaluation), which command used to do the job you just explained to me? for example with my 150 data partitioned, would I still need to declare the vectors below before doing the work you explained to me? if not how i have to call this data in order to build it?
x_Train = [4 6 7 5 8; 5.2 6.3 9 11 10];
y_Train = [3 7 8 5 8;4.5 1.3 6 7 9.1];
x_test=[0.8 14 2 5 4.3; 7.2 6.5 4.1 18 3.6];
y_test=[1 4.8 5.9 14 3.4 9 17 12 16 2.9];
['None', 'OCF', 'SCF', 'P', 'SBD', 'OCI']
best regards
  4 个评论
Image Analyst
Image Analyst 2023-1-4
You have this:
x_train = mydata1_train(:,1); %[4 6 7 5 8];
y_train = mydata1_train(:,2); % [3 7 8 5 8];
% Now you say your classes are c=['open,'short','short','open','open']
% so let's make those class numbers.
trainClass =[1,2,2,1,1];
However your x_train and y_train have 120 elements. So you need to define trainClass to have 120 elements also. You need to know the "true" class for every one of your training points. Right now you have only 5, not 120.
merlin toche
merlin toche 2023-2-16
please can someone help me?
I want to detect a series of faults using the fuzzy-KNN algorithm. for this I have 5 name data classes, I wrote a code but errors appear, I would like your help to reread and make the necessary corrections.
attached my code and my dataset
THANKS

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by