'Returns the type with the highest probability for the given document.
If the classifier has been trained on LSA concept vectors
you need to supply LSA.transform(document).'

def classify(self, document, discrete=True):

    classes = {}
    v1 = self._vector(document)[1]
    D = ((distance(v1, v2, method=self.distance), type) for (type, v2) in self._vectors)
    D = ((d, type) for (d, type) in D if (d < 1))
    D = heapq.nsmallest(self.k, D)
    s = (sum(((1 - d) for (d, type) in D)) or 1)
    p = defaultdict(float)
    for (d, type) in D:
        p[type] += ((1 - d) / s)
    if (not discrete):
        return Probabilities(self, p)
    try:
        m = max(p.values())
        p = sorted(((self._classes[type], type) for (type, w) in p.items() if (w == m > 0)))
        p = [type for (frequency, type) in p if (frequency == p[0][0])]
        return choice(p)
    except:
        return self.baseline
