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

Method __init__

pattern/vector/__init__.py:1666–1680  ·  view source on GitHub ↗

A base class for Naive Bayes, k-NN and SVM. Trains a classifier on the given list of Documents or (document, type)-tuples, where document can be a Document, Vector, dict or string (dicts and strings are implicitly converted to vectors).

(self, train=[], baseline=FREQUENCY, **kwargs)

Source from the content-addressed store, hash-verified

1664class Classifier(object):
1665
1666 def __init__(self, train=[], baseline=FREQUENCY, **kwargs):
1667 """ A base class for Naive Bayes, k-NN and SVM.
1668 Trains a classifier on the given list of Documents or (document, type)-tuples,
1669 where document can be a Document, Vector, dict or string
1670 (dicts and strings are implicitly converted to vectors).
1671 """
1672 self._vectors = [] # List of trained (type, vector)-tuples.
1673 self._classes = {} # Dict of (class, frequency)-items.
1674 self._baseline = baseline # Default predicted class.
1675 # Train on the list of Document objects or (document, type)-tuples:
1676 for d in (isinstance(d, Document) and (d, d.type) or d for d in train):
1677 self.train(*d)
1678 # In Pattern 2.5-, Classifier.test() is a classmethod.
1679 # In Pattern 2.6+, it is replaced with Classifier._test() once instantiated:
1680 self.test = self._test
1681
1682 @property
1683 def features(self):

Callers

nothing calls this directly

Calls 1

trainMethod · 0.95

Tested by

no test coverage detected