Giter Club home page Giter Club logo

pybayes's Introduction

PyBayes

Note: this software is not maintained since 2014.

About

PyBayes is an object-oriented Python library for recursive Bayesian estimation (Bayesian filtering) that is convenient to use. Already implemented are Kalman filter, particle filter and marginalized particle filter, all built atop of a light framework of probability density functions. PyBayes can optionally use Cython for large speed gains (Cython build can be several times faster in some situations).

PyBayes is tested with Python 2.7, 3.2 and 3.3 (using 2to3). Future plans include more specialised variants of Kalman/particle filters and speed optimisations.

PyBayes is being developed by Matěj Laitl, feel free to send me a mail to matej at laitl dot cz. See ChangeLog.rst file to review a list of most important changes in recent versions.

Automatically generated documentation can be found at http://strohel.github.com/PyBayes-doc/

Licensing

PyBayes is distributed under the MIT license.

Obtaining PyBayes

PyBayes releases can be found in .tar.gz format at github or PyPI. Binary packages for CentOS, Debian, Fedora, RHEL, OpenSUSE and Ubuntu can be downloaded from the OpenSUSE Build Service; these packages are fast Cython builds. (with no requirement to install Cython for building)

Development of PyBayes happens on http://github.com/strohel/PyBayes using git VCS and the most fresh development sources can be obtained using git:

# cd path/to/projects
# git clone git://github.com/strohel/PyBayes.git

Installing PyBayes

PyBayes uses standard Python distutils for building and installation. Follow these steps in order to install PyBayes:

  • download PyBayes, let's assume PyBayes-0.1.tar.gz filename

  • unpack it:

    tar -xvf PyBayes-0.1.tar.gz

  • change directory into PyBayes source:

    cd Pybayes-0.1

  • build and install (either run as root or install to a user-writeable directory [1]):

    ./setup.py install

[1]http://docs.python.org/install/#alternate-installation

And you're done! However, if you want PyBayes to be considerably faster, please read the following section.

Advanced installation options

PyBayes can use Cython to build itself into binary Python module. Such binary modules are transparent to Python in a way that Python treats then as any other modules (you can import them as usual). Interpreter overhead is avoided and many other optimisation options arise this way.

In order to build optimised PyBayes, you'll additionally need:

  • Cython Python to C compiler, version 0.18 or newer is recommended
  • working C compiler (GCC on Unix-like systems, MinGW or Microsoft Visual C on Windows [2])
  • NumPy numerical library for Python, version 1.5 or greater (NumPy is needed also in Python build, but older version suffice in that case)
  • Ceygen Python package 0.3 or greater installed to a standard location
  • On some Debian-based Linux distributions (Ubuntu) you'll need python-dev package that contains Python.h file that is needed by PyBayes
[2]http://docs.cython.org/src/quickstart/install.html

Proceed with following steps:

  1. Install all required dependencies. They should be already available in your package manager if you use a modern Linux Distribution.

  2. Unpack and install PyBayes as described above, you should see following message during build:

    Cython and NumPy found, enabling optimised Cython build.

    • in order to be 100% sure that optimised build is used, you can add --use-cython=yes option to the ./setup.py call. You can force pure Python mode even when Cython is installed, pass --use-cython=no. By default, PyBayes auto-detects Cython and NumPy presence on system.
    • if you plan to profile code that uses optimised PyBayes, you may want to embed profiling information into PyBayes. This can be accomplished by passing --profile=yes to ./setup.py. The default is to omit profiling information in order to avoid performance penalties.
    • all standard and custom build parameters can be listed using ./setup.py --help

The best results performance-wise are achieved when also your code that uses or extends PyBayes is compiled by Cython and uses static typing where appropriate. Remember to cimport pybayes[.something] everytime you import pybayes[.something] so that fast Cython calling convention is used.

Building Documentation

There is no need to build documentation yourself, an online version is at http://strohel.github.com/PyBayes-doc/

PyBayes uses Sphinx to prepare documentation, version 1.0 or greater is required. The documentation is built separately from the python build process. In order to build it, change directory to doc/ under PyBayes source directory (cd [path_to_pybayes]/doc) and issue make command. This will present you with a list of available documentation formats. To generate html documentation, for example, run make html and then point your browser to [path_to_pybayes]/doc/_build/html/index.html.

PyBayes docs contain many mathematical expressions; Sphinx can use LaTeX to embed them as images into resulting HTML pages. Be sure to have LaTeX-enabled Sphinx if you want to see such nice things.

Testing

PyBayes comes with a comprehensive test and stress-suite that can and should be used to verify that your PyBayes build works as expected.

Since version 0.4, testing is integrated into the setup.py script and can be run without installing PyBayes. In order to run PyBayes test-suite, simply issue ./setup.py test from within the source directory. To run tests during installation procedure, simply install like this: ./setup.py build test install. With this command, failing tests prevent installation.

If you want to test your already installed PyBayes instance, simply issue python -m pybayes.tests anytime, anywhere. :-)

Stress-testing

Stress-testing works similarly to unit testing since version 0.4, run it using ./setup.py stress from the source directory. Already installed PyBayes can be stress-tested using python -m pybayes.stresses.

pybayes's People

Contributors

simongreenhill avatar strohel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pybayes's Issues

Relicense under BSD

I think there are many good reasons to not go with GPL these days. Mainly it prevents other OSS developers using more liberal licenses like MIT, BSD or Apache from using your code.

Question regarding EmpPdf

Hello, please forgive this somewhat noobish question.

I am hoping to use this library for some particle filtering. However the p_yt_xt cpdf that I would like to supply is an empirical cpdf. That is, x_t can take on various discrete values, and each value of x_t has its own pdf for y_t.

Trivial example,

low = pb.pdfs.EmpPdf(np.array([[0.],[1.]], ndmin=2))
high = pb.pdfs.EmpPdf(np.array([[0.],[1.],[1.],[1.]], ndmin=2))

Now we'd like to construct a cpdf which, when x_t = 0, y_t follows the low pdf and when x_t = 1 it follows the high pdf.
To do this, I could try to make a subclass of EmpPdf called ConditionalEmpPdf, but maybe I'm misunderstanding something about the code base and this functionality is already provided or is composable from existing classes.

Also I can't tell from the code if it is set up to correctly handle discrete probability functions like this.

Thanks in advance! —David

Add examples

I couldn't find a set of easy examples on how to use PyBayes. Are they present somewhere?

Install under Python 3

As far as I can tell this does not install under py3 (pip install PyBayes):

  File "/tmp/pip_build_fil/PyBayes/setup.py", line 23

    print "Failed to determine version using git:", e

What is the usual strategy here - can you pass a setup.py's code through 2to3?

Binary for Windows

Anyone try to install on windows? I got an error:

Collecting PyBayes Using cached https://files.pythonhosted.org/packages/e5/12/84e4ffaf167968c824a5cf2c9e1b5edaf6c0c9f920c93cb8cc4337f7cbbd/PyBayes-0.3.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\czhou\AppData\Local\Temp\pip-install-zqvu4hb6\PyBayes\setup.py", line 23 print "Failed to determine version using git:", e ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Failed to determine version using git:", e)?

Vector multiplication error

Hi,
I'm using the deb package available in Ubuntu 16.04. I'm experiencing this error with PyBayes:

File "/home/manolofc/catkin_ws/src/RFID/pr_model/scripts/frequencyModel.py", line 151, in addObservation
    self.pf.bayes(yt)
  File "/usr/local/lib/python2.7/dist-packages/pybayes/filters.py", line 322, in bayes
    self.emp.weights[i] *= exp(self.p_yt_xt.eval_log(yt, self.emp.particles[i]))
  File "/usr/local/lib/python2.7/dist-packages/pybayes/pdfs.py", line 1300, in eval_log
    return self.gauss.eval_log(x)
  File "/usr/local/lib/python2.7/dist-packages/pybayes/pdfs.py", line 568, in eval_log
    log_val = -1/2. * np.dot_vv(distance, np.dot_mv(linalg.inv(self.R), distance))
ValueError: shapes (2,) and (1,2) not aligned: 2 (dim 0) != 1 (dim 0)

It seems to be related with the observation and state dimensions. In my case yt has dimension 2 and xt dimension 3. Any idea of what could be wrong?
Thanks

Building issues for Ceygen (and PyBayes)

When building the library on Ubuntu I get the command x_86_64-linux-gnu-gcc failed with exit status 1 error. I don't know where the compiler is failing and here is a copy of the trace for it:

Cythonizing ceygen/tests/test_reductions.pyx
building 'ceygen.dtype' extension
creating build/temp.linux-x86_64-3.4/build
creating build/temp.linux-x86_64-3.4/build/temp.linux-x86_64-3.4
creating build/temp.linux-x86_64-3.4/build/temp.linux-x86_64-3.4/ceygen
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/local/lib/python3.4/dist-packages/Ceygen/ceygen -I/usr/include/eigen3 -I/usr/include/python3.4m -c build/temp.linux-x86_64-3.4/ceygen/dtype.cpp -o build/temp.linux-x86_64-3.4/build/temp.linux-x86_64-3.4/ceygen/dtype.o -O2 -march=native -fopenmp
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.4/build/temp.linux-x86_64-3.4/ceygen/dtype.o -o build/lib.linux-x86_64-3.4/ceygen/dtype.cpython-34m.so -fopenmp
building 'ceygen.llt' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/local/lib/python3.4/dist-packages/Ceygen/ceygen -I/usr/include/eigen3 -I/usr/include/python3.4m -c build/temp.linux-x86_64-3.4/ceygen/llt.cpp -o build/temp.linux-x86_64-3.4/build/temp.linux-x86_64-3.4/ceygen/llt.o -O2 -march=native -fopenmp
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from build/temp.linux-x86_64-3.4/ceygen/llt.cpp:349:0:
build/temp.linux-x86_64-3.4/ceygen/eigen_cpp.h:18:22: fatal error: Eigen/Core: No such file or directory
#include <Eigen/Core>
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.