'Print a table showing the effect of each of the features in
the given feature set, and how they combine to determine the
probabilities of each label for that featureset.'

def explain(self, featureset, columns=4):

    descr_width = 50
    TEMPLATE = ((u'        %-' + str((descr_width - 2))) + u's%s%8.3f')
    pdist = self.prob_classify(featureset)
    labels = sorted(pdist.samples(), key=pdist.prob, reverse=True)
    labels = labels[:columns]
    print((u'        Feature'.ljust(descr_width) + u''.join(((u'%8s' % (u'%s' % l)[:7]) for l in labels))))
    print((u'        ' + (u'-' * ((descr_width - 2) + (8 * len(labels))))))
    sums = defaultdict(int)
    for (i, label) in enumerate(labels):
        feature_vector = self._encoding.encode(featureset, label)
        feature_vector.sort(key=(lambda fid__: abs(self._weights[fid__[0]])), reverse=True)
        for (f_id, f_val) in feature_vector:
            if self._logarithmic:
                score = (self._weights[f_id] * f_val)
            else:
                score = (self._weights[f_id] ** f_val)
            descr = self._encoding.describe(f_id)
            descr = descr.split(u'    and    label    is    ')[0]
            descr += (u'    (%s)' % f_val)
            if (len(descr) > 47):
                descr = (descr[:44] + u'...')
            print((TEMPLATE % (descr, ((i * 8) * u'    '), score)))
            sums[label] += score
    print((u'        ' + (u'-' * ((descr_width - 1) + (8 * len(labels))))))
    print((u'        TOTAL:'.ljust(descr_width) + u''.join(((u'%8.3f' % sums[l]) for l in labels))))
    print((u'        PROBS:'.ljust(descr_width) + u''.join(((u'%8.3f' % pdist.prob(l)) for l in labels))))
