Exemplo n.º 1
0
    def get_distance_weighted_label(distances, labels, numNeighbours):
        """Returns the the distance weighted label of the k nearest neighbors."""
        nnIndices = libNearestNeighbor.nArgMin(numNeighbours, distances)
        sqrtDistances = np.sqrt(distances[nnIndices])
        if not isinstance(labels, type(np.array([]))):
            labels = np.asarray(labels, dtype=np.int8)
        else:
            labels = np.int8(labels)

        predLabels = libNearestNeighbor.getLinearWeightedLabels(labels[nnIndices], sqrtDistances)
        return predLabels
Exemplo n.º 2
0
 def getDistanceWeightedLabel(distances, labels, numNeighbours):
     """Returns the the distance weighted label of the k nearest neighbors."""
     nnIndices = libNearestNeighbor.nArgMin(numNeighbours, distances)
     sqrtDistances = np.sqrt(distances[nnIndices])
     predLabels = libNearestNeighbor.getLinearWeightedLabels(labels[nnIndices], sqrtDistances)
     return predLabels