The PSMPyLib software package exposes functionality of the the PSMSLib C++ library to Python in the form of an extension module named 'psm'. It uses Boost.Python to generate most of the binding code. Before using the 'psm' Python module, you may wish to familiarize yourself with the PSMSLib C++ API documentation, since the Python interface is merely a thin wrapper around the C++ API.
Below is a toy example showing the use of the 'psm' module in a Python script:
cm = psm.PPMFileClassificationModel.create('model.bin')
cm.train(psm.class_identifier.positive, 'positive example string')
cm.train(psm.class_identifier.positive, 'another positive example')
cm.train(psm.class_identifier.negative, 'negative example string')
cl = psm.PPMFileClassifier(cm, 6) # Create an order-6 PPM classifier
log_odds = cl.get_log_odds(psm.evaluation_mode.static, 'test string')
if log_odds > 0:
print 'Test example is positive'
print 'Test example is negative'
This software is the property of Klika d.o.o. Permission is granted to use this software for research purposes and/or for personal use. This software may not be used for any commercial purposes. The use of the Python extension module in other non-commercial software is permitted; However, any copy of the extension module may only be used under these terms, even when used implicitly through the use of other software. The software is provided "as is" without express or implied warranty of any kind. Read the full terms before downloading any packages.
*Download this package if you are running Python 2.3 or Python 2.4 on Windows.
**Download this package if you intend to build your Python extension module from source.
The author of this software is Andrej Bratko. The PSMPyLib Python extension module was originally written to facilitate integration of the Probabilistic Sequence Modeling Shared Library (PSMSLib) with the Orange data mining toolkit. Contact the author if you are interested in commercial applications of this software.