knn grouping matrix representation
Mostrar comentarios más antiguos
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
Respuestas (1)
Walter Roberson
el 4 de Mayo de 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])
Categorías
Más información sobre Nearest Neighbors en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!