Posts Tagged ‘Bayesian’
In this post I will document my installation of (the bleeding edge, development version) of scikit-learn. You might not want to do this — there are stable releases with installation instructions available at the package website. In fact, there are Ubuntu/Debian-specific installation instructions. I would suggest using the Ubuntu package unless you know that you need that latest code. The reason for this is that dependencies will be taken care of by the package manager; otherwise you will have to figure out the dependencies yourself.
Now on to the specifics, assuming you want to install this version. First, change to a directory where you want the git repository to live, and clone the github repository:
git clone git://github.com/scikit-learn/scikit-learn.git
Following the instructions, change directory to the repository and use the included Makefile
cd scikit-learn make
This will build the package locally and run a bunch of tests (~2600 using nosetests) to make sure that everything works on you computer.
The commands in the Makefile do not install the package on the system. Instead, the scikit-learn website suggests including the path of the (built) package in your
PYTHONPATH. I will do this in a slightly unconventional way that does not require admin privileges, allows the path to be included for a specific version of python, for a single user, and employs basic
bash commands (this follows ideas from here — look for subsection on The bash way).
First, find out where your version of python has the user site-packages directory.
python -m site --user-site
If you have multiple versions of python installed and just want to affect python 2.6 you would use
python2.6 -m site --user-site instead. Next, the directory provided by the above command may not exist. To make sure that it does, make the needed directory:
mkdir -p $(python -m site --user-site)
python2.6 in the above if you need to be more specific. Finally, we make a mypath.pth file in this directory that allows python to find scikit-learn:
echo "/home/username/gitLocal/scikit-learn" >> $(python -m site --user-site)/mypath.pth
This assumes that you cloned the scikit-learn repository in
~/gitLocal/. If you did not, change the above to reflect the location for you computer. Again, change the version of python employed, it needed.
Everything should be setup now. To test, cd to you home directory (make sure you are not in the scikit-learn directory) and start python:
cd ~ python
Now, import scikit-learn (hopefully without error):
PyMC is a nice Python package for implementing MCMC sampling in Bayesian inference. I have used this package on a variety of projects in Ubuntu 10.04lts and will provide my notes on how to install the development version from the github repository. This is important for me because I have found a variety of instances where I needed the latest PyMC version to accomplish particular goals.
To start, make sure some dependencies are installed:
sudo apt-get install python-dev gcc gfortran
If, like me, you already have many Python packages installed you will have some or most of the above installed. Next, cd to a directory where you would like to keep the PyMC git repository on your machine and clone the repository:
git clone git://github.com/pymc-devs/pymc.git
Finally, compile and install
cd pymc/ sudo python setup.py config_fc --fcompiler gfortran build sudo python setup.py install