def condensed_nearest_neighbor(self, k=1, distance=COSINE):
        d = DistanceMap(method=distance)
        u = []
        v = list(self.documents)
        b = False
        while not b:
            b = True
            for i, x in enumerate(v):
                nn = heapq.nsmallest(k, ((d(x.vector, y.vector), y) for y in u))
                if not u or x.type in (y.type for d, y in nn):
                    b = False
                    u.append(x)
                    v.pop(i)
                    break
        return v
Returns a filtered list of documents, without impairing classification accuracy.
dataset/ETHPy150Open clips/pattern/pattern/vector/__init__.py/Model.condensed_nearest_neighbor