'Calls libsvm.svm_predict() with the cached model.
For CLASSIFICATION, returns the predicted class.
For CLASSIFICATION with probability=True, returns a {class: weight} dict.
For REGRESSION, returns a float.'

def _classify(self, document, probability=False):

    if (self._model is None):
        return None
    M = self._model[0]
    H1 = self._model[1]
    H2 = self._model[2]
    H3 = self._model[3]
    n = len(H1)
    v = self._vector(document)[1]
    v = dict(map((lambda k: (H1.get(k[1], ((k[0] + n) + 1)), v[k[1]])), enumerate(v)))
    s = getattr(self, '_solver', None)
    if (self.extension == LIBLINEAR):
        f = self._svm.liblinearutil.predict
        o = ('-b    %s    -q' % (int(probability) if (s == 0) else 0))
    else:
        f = self._svm.libsvmutil.svm_predict
        o = ('-b    %s    -q' % int(probability))
    p = f([0], [v], M, o)
    if ((self._type == CLASSIFICATION) and probability and (self.extension == LIBLINEAR) and (s != 0)):
        return Probabilities(self, defaultdict(float, ((H3[p[0][0]], 1.0),)))
    if ((self._type == CLASSIFICATION) and probability and (self.extension == LIBLINEAR)):
        return Probabilities(self, defaultdict(float, ((H3[(i + 1)], w) for (i, w) in enumerate(p[2][0]))))
    if ((self._type == CLASSIFICATION) and probability):
        return Probabilities(self, defaultdict(float, ((H3[(i + 0)], w) for (i, w) in enumerate(p[2][0]))))
    if (self._type == CLASSIFICATION):
        return H3.get(int(p[0][0]))
    if (self._type == REGRESSION):
        return p[0][0]
    if (self._type == DETECTION):
        return (p[0][0] > 0)
    return p[0][0]
