Returns the type with the highest probability for the given document. Returns a dict of (class, probability)-items if discrete=False.
(self, document, discrete=True)
| 1750 | self._classes[type] = self._classes.get(type, 0) + 1 |
| 1751 | |
| 1752 | def classify(self, document, discrete=True): |
| 1753 | """ Returns the type with the highest probability for the given document. |
| 1754 | Returns a dict of (class, probability)-items if discrete=False. |
| 1755 | """ |
| 1756 | # This method must be implemented in subclass. |
| 1757 | if not discrete: |
| 1758 | return defaultdict(float) |
| 1759 | return self.baseline |
| 1760 | |
| 1761 | def _vector(self, document, type=None): |
| 1762 | """ Returns a (type, Vector)-tuple for the given document. |
no outgoing calls