Is there a popular implementation of Conditional Random Fields in Python?
I can't seem to find any that is widely used and popular!
Is there a popular implementation of Conditional Random Fields in Python?
I can't seem to find any that is widely used and popular!
CRF++ is a popular choice in general, and has Python bindings. CRFSuite also has bindings documented here, but doesn't seem to have seen as much widespread use as CRF++. As of this writing, higher level machine learning frameworks such as scikit-learn lack CRF support (see this pull request).
CRF++ has more incoming links because it is an older library.
CRFSuite is superior in my opinion.
If you are looking for Python bindings CRFSuite is also better because you can train a model in Python, while in CRF++ you can only test existing models in Python. (That was the deal breaker for me.) CRFSuite also comes with a bunch of example code in Python, such as NER, Chunking, and POS tagging.
Here are some other wrappers/implementations:
exit()
, and I've seen memory leaks during the training. Also, wapiti is limited in a type of features it can represent, but CRFsuite is also limited (in a different way). Wapiti is bundled in a wrapper, no need to install it separately.I'd recommend to use seqlearn if you can, python-crfsuite if you need CRFsuite training algorithms and training speed, pyCRFsuite if you need more advanced CRFsuite integration and ready to face some inconveniences, python-wapiti if you need Wapiti training algorithms or features not available in CRFsuite (like conditioning individual observations on transitions) and timvieira's crf if there is no way to get a C/C++ compiler working, but a prebuilt numpy is available.
I think what you are looking for is PyStruct.
PyStruct aims at being an easy-to-use structured learning and prediction library. Currently it implements only max-margin methods and a perceptron, but other algorithms might follow.
The goal of PyStruct is to provide a well-documented tool for researchers as well as non-experts to make use of structured prediction algorithms. The design tries to stay as close as possible to the interface and conventions of scikit-learn.
PyStruct
comes with good documentation, and it is actively developed on github.
Below is a table comparing PyStruct
with CRFsuite
and other packages, extracted from PyStruct - Structured prediction in Python: