Wiki
Clone wikibnpy-dev / Installation
This document should provide all the steps to get bnpy installed on your computer.
Dependencies
bnpy depends on Python and the following (external) Python packages
Required
- numpy (version 1.8 or later)
- scipy
Optional for visualization
- matplotlib
Optional for faster execution of learning algorithms
- numexpr
-
- Python module. Used for fast multi-core evaluation of
exp()
,log()
, and other functions.
- Python module. Used for fast multi-core evaluation of
- Eigen matrix library, version 3 or later.
-
- C++ template library. Used for HMM inference only. To install, see compilation instructions.
Installing a Python stack with all required modules
Recommended installation
We highly recommend the Enthought Python distribution.
It's one-click install comes with all the requirements for bnpy and avoids the hassle of individually installing each package.
Furthermore, the numerical subroutines for matrix operations that ship with the EPD are almost always better than what a novice user can build themselves from source or have installed from other routes. We've routinely observed speedups of 2-4x on basic operations like matrix multiplication.
Alternate installation
The Anaconda distribution of Python will probably also be successful.
Finally, you can build the dependencies like numpy and scipy from source, or install via a package manager like "easy_install" or "pip". If you must go this route, we recommend using pip. You can search the web for the latest and greatest instructions for installing these. This route requires lots of manual effort and is only recommended as a last resort for experts.
Installing bnpy
You can grab the latest stable version from our active-development git repository, known as bnpy-dev.
Execute the following command to have the project file structure cloned to your local disk, within a folder called "bnpy-dev"
git clone https://michaelchughes@bitbucket.org/michaelchughes/bnpy-dev/
Make sure everything works!
Throughout all documentation, we'll call the directory where bnpy is installed $BNPYROOT
. Wherever you see this, substitute in the actual directory on your system.
If you execute ls $BNPYROOT
, you should see a README.md file and folders like "bnpy/", "datasets/", and more.
Verify numpy install
Open a terminal, and type python
to drop into a python shell. Then type.
import numpy print numpy.__version__
Verify matplotlib install
Open a terminal, type python
to drop into a python shell. Then type
from matplotlib import pylab pylab.plot([1,2,3]) pylab.show()
If that produces a figure with a simple line plot, you're good to go!
Common errors
If you try the above and get errors about not having "wx" or "wxpython" or "qt" installed, you need to configure your matplotlib backend.
See Matplotlib documentation for answers.
I recommend setting your matplotlibrc file to have backend: TkAgg
for Linux, and backend: MacOSX
for Mac.
Optional: Fast C++ libraries for HMM inference
By default, bnpy code will use normal Python code to do expensive dynamic programming required by the local step of HMM inference. However, you can speed this up by building a C++ library called libfwdbwd
, as follows:
$ cd $BNPYROOT $ export EIGENPATH=/path/to/eigen3/ $ make libfwdbwd
- Gnu C++ compiler
-
- If you can type
which g++
at the terminal, you are good.
- If you can type
-
- Windows users may experience bugs. Please submit error reports.
- Eigen matrix library
-
- Must be installed on your system in a location specified by
EIGENPATH
environment variable.
- Must be installed on your system in a location specified by
Once compiled via the make command, bnpy will automatically use the libfwdbwd
C++ library instead of the pure Python versions of dynamic programming algorithms (see HMMUtil.py for details). Note that these have been designed to produce exactly the same output, so speed is the only difference.
Updated