MCPcopy Index your code
hub / github.com/clips/pattern / train

Method train

pattern/vector/__init__.py:1743–1750  ·  view source on GitHub ↗

Trains the classifier with the given document of the given type (i.e., class). A document can be a Document, Vector, dict, list or string. If no type is given, Document.type will be used instead.

(self, document, type=None)

Source from the content-addressed store, hash-verified

1741 return moment(a, m, 3) / (moment(a, m, 2) ** 1.5 or 1)
1742
1743 def train(self, document, type=None):
1744 """ Trains the classifier with the given document of the given type (i.e., class).
1745 A document can be a Document, Vector, dict, list or string.
1746 If no type is given, Document.type will be used instead.
1747 """
1748 type, vector = self._vector(document, type)
1749 self._vectors.append((type, vector))
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.

Callers 2

__init__Method · 0.95
_test_classifierMethod · 0.95

Calls 3

_vectorMethod · 0.95
appendMethod · 0.45
getMethod · 0.45

Tested by 1

_test_classifierMethod · 0.76