'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):

    v = self._vector(document)[1]
    m = self._method
    a = self._alpha
    n = self._classes.values()
    n = float(sum(n))
    p = defaultdict(float)
    for type in self._classes:
        if (m == MULTINOMIAL):
            if (not (type in self._cache)):
                self._cache[type] = float(sum(self._likelihood[type].values()))
            d = self._cache[type]
        if ((m == BINOMIAL) or (m == BERNOUILLI)):
            d = float(self._classes[type])
        L = self._likelihood[type]
        g = sum((log(((L[f] if (f in L) else a) / d)) for f in v))
        g = ((exp(g) * self._classes[type]) / n)
        p[type] = g
    s = (sum(p.values()) or 1)
    for type in p:
        p[type] /= s
    if (not discrete):
        return Probabilities(self, p)
    try:
        m = max(p.values())
        p = sorted(((self._classes[type], type) for (type, g) in p.items() if (g == m > 0)))
        p = [type for (frequency, type) in p if (frequency == p[0][0])]
        return choice(p)
    except:
        return self.baseline
