Description Usage Arguments Details Value Author(s)
View source: R/SpecimenIDing_functions.R
This function takes a vector of distances to an unknown specimen that is to be identified and returns an identification for the specimen. This function applies both a weighted approach and an unweighted appraoch and returns both results.
1 2 3 4 5 6 | KnnIDingSingleInd(
X,
K,
GroupMembership,
TieBreaker = c("Random", "Remove", "Report")
)
|
X |
a numeric vector of distances from the unknown specimen to the all the reference specimens. |
K |
is the number of nearest neighbours that the method will use for assigning group classification. |
GroupMembership |
a character or factor vector in the same order as the distance data to denote group membership. |
TieBreaker |
is the method used to break ties if there is no majority resulting from K. Three methods are available('Random', 'Remove' and 'Report'): Random randomly returns one of tied classifications; Remove returns 'UnIDed' for the classification; Report returns a the multiple classifications as a single character string with tied classifications separated by '_'. NOTE: for correct cross-validation proceedures the results of both Report will be considered an incorrect identification even if one of the multiple reported classifications is correct. |
The function calculates the classification based on a majority vote from k nearest neighbours. The method also calculates the classification using a weighted approach. In the weighted approach each of the k nearest neighbours are given a weight calculated as 1/distance. The weights are summed by group for the k nearest neighbours and the unknown specimen is assigned to the group with the highest summed weight.
Returns a list of two objects, the classification result from a weighted approach and the classification result from an unweighted approach.
Ardern Hulme-Beaman
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.