knn grouping matrix representation
Afficher commentaires plus anciens
I am new to using KNN and was told that use grouping matruix in the following format for example,
G=[1;1;1;1;1;1;1;1;1;1;2;2;2;2;2;2;2;;3;3;3;3;3;3;3;3;4;4;4;4;4;4;4;4]
surly, supposed i have 500 trainig sample data, woukd i have to put in G 500 numbers and so on? this is not scalable? there must a shorter way of representing G. Thanks you
Réponses (1)
Walter Roberson
le 4 Mai 2017
G = [repmat(1, 1, number_in_first_group), repmat(2, 1, number_in_second_group), repmat(3, 1, number_in_third_group)]
Or
G = [ones(1, number_in_first_group), 2 * ones(1, number_in_second_group), 3 * ones(1, number_in_third_group)]
or
G = repelems([1, 2, 3], [number_in_first_group, number_in_second_group, number_in_third_group])
Catégories
En savoir plus sur Nearest Neighbors dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!