- Notifications
You must be signed in to change notification settings - Fork3
Python 3.7 version of David Barber's MATLAB BRMLtoolbox
License
MauroCE/PythonBRMLtoolbox
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
BRMLtoolboxin Python 3.7. My goal with this repository is to:
- Learn BRMLtoolbox with an insider perspective
- Provide a Python package for BRMLtoolbox which is availablein MATLAB, Python 2.7 and Julia.
- Improve my Python skills
When initializing a potential we can pass variables as argumentsin different ways:
- We can pass a scalar value (
intorfloat) when we onlyhave 1 variable. (We could also pass a list or a numpy arraywith only one value)
importnumpyasnpfrombrml.arrayimportArraypot=Array(variables=1)pot2=Array(variables=1.0)pot3=Array(variables=[1])pot4=Array(variables=np.array([1]))pot5=Array(variables=np.array([[1]]))
- We can pass a
listor anumpy.arraywhen we have multiple variables.
importnumpyasnpfrombrml.arrayimportArraypot=Array(variables=[1,2])pot2=Array(variables=np.array([1,2]))pot3=Array(variables=np.array([[1,2]]))pot4=Array(variables=np.array([[1], [2]]))
All of these calls are equivalent among them because they are all converted toa 1Dnumpy.array (notice that in MATLAB, because 1D arrays don't exist, thisis different).It might be good to discuss whether it is better to convert all of these to 1Dnumpy.array or to a 2D array with shape(1, n) wheren is the number ofvariables.
It is worth mentioning that you don't need to pass variables on initialization.You can initialize an array without variables and without table, and add the later.For example:
importnumpyasnpfrombrml.arrayimportArraypot=Array()pot.set_variables(np.array([1,2]))
Notice, however, that you CANNOT initialize variables before initializing the table.That is, you cannot initialize an empty arraypot = Array() and then callpot.set_table(np.array([0.4, 0.6])) because this will throw an error. You mustfirst useset_variables method, and after use theset_table method. If, instead,you decide to pass variables and table on initialization, then everything will be fine.
Go tocheck/potential_variables.py and you'll find a test to checkthat the statements above are correct!
The BRMLtoolbox is a MATLAB toolbox written by David Barber, Reader for the Computational Statistics and Machine Learning MSc at UCL. The BRML toolbox should be used together with the book Bayesian Reasoning and Machine Learning. It is a set of tools to help readers see how mathematical models translate into actual code.
- Python (3.6 onwards, although only type hints would need to be removed for Python 3.5)
- Numpy
The mathematical requirements for understanding classes within BRML toolbox are:
- Calculus & Linear Algebra
- Probability
- Algorithms
- Statistics (Bayesian mainly)I am currenlty trying to write an introduction to Probability here inmy Proofwiki account, although it is just a draft for now.
Please feel free to contribute to this python version of the BRML toolbox! There are already a few incomplete implementations of the code, hopefully this version will be more up-to-date and efficient with your help!
As I said earlier BRML toolbox comes withBayesian Reasoning and Machine Learning book.
@BOOK{barberBRML2012,author = {Barber, D.},title= {{Bayesian Reasoning and Machine Learning}},publisher = {{Cambridge University Press}},year = 2012}About
Python 3.7 version of David Barber's MATLAB BRMLtoolbox
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.