KnnIDingSingleInd: K-Nearest Neighbour single specimen identification

Description Usage Arguments Details Value Author(s)

View source: R/SpecimenIDing_functions.R

Description

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.

Usage

1
2
3
4
5
6
KnnIDingSingleInd(
  X,
  K,
  GroupMembership,
  TieBreaker = c("Random", "Remove", "Report")
)

Arguments

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.

Details

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.

Value

Returns a list of two objects, the classification result from a weighted approach and the classification result from an unweighted approach.

Author(s)

Ardern Hulme-Beaman


ArdernHB/KnnDist documentation built on Feb. 5, 2021, 5:09 a.m.