def get_maj_label(distances, labels, numNeighbours): """Returns the majority label of the k nearest neighbors.""" nnIndices = libNearestNeighbor.nArgMin(numNeighbours, distances) if not isinstance(labels, type(np.array([]))): labels = np.asarray(labels, dtype=np.int8) else: labels = np.int8(labels) predLabels = libNearestNeighbor.mostCommon(labels[nnIndices]) return predLabels
def getMajLabel(distances, labels, numNeighbours): """Returns the majority label of the k nearest neighbors.""" nnIndices = libNearestNeighbor.nArgMin(numNeighbours, distances) predLabels = libNearestNeighbor.mostCommon(labels[nnIndices]) return predLabels