how can I limit the search for kNN (fitcknn) if I have multiple classes in training but just want to compare the distance to few classes

1 visualizzazione (ultimi 30 giorni)
Hello to all,
how can I limit the classes to few selected.
suppose we have: Bending; Sitting; Standing; FAlling; Walking
in the training
but I just want to compare is it Bending or Walking
while i is the sample and m is the class (five in total) and x is the image
mdl_MD = fitcknn(P_train,movs(trainIdx),'NumNeighbors',3,'Distance','euclidean');
predict(P_train,P_test)
It computes the distance to all classes but I want the distance just to two as I said without computing a new .
I assume this must be possible with the functions fitcknn or predict, but how.
Thank you in advanced for your help.

Risposta accettata

Image Analyst
Image Analyst il 19 Ott 2019
Only pass in the columns you want, like
pTrain = movs(:, [1,4]); % Extract only bending and walking columns.
testData = movs(:, [1,4]); % Extract only bending and walking columns.
mdl_MD = fitcknn(pTrain,testData,'NumNeighbors',3,'Distance','euclidean');

Più risposte (0)

Categorie

Scopri di più su Statistics and Machine Learning Toolbox in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by