'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]
    i = (self._iteration or 1)
    i = float(i)
    p = defaultdict(float)
    for (type, w) in self._weight.items():
        s = 0.0
        for f in v:
            if (f in w):
                (w0, w1, j) = w[f]
                s += ((((i - j) * w0) + w1) / i)
        p[type] = s
    p = softmax(p)
    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
