Notes on Ubuntu (Linux) computing

Brief notes on installation, setup and other tasks in the Ubuntu world

Archive for November 2013

Install vim-template vim plugin

leave a comment »

The vim-template plugin allows for the use of templates for different file types: *.html, *.py and so on. Following the installation instructions (see above link), we use pathogen to install the plugin:

cd ~/.vim/bundle
git clone git://github.com/aperezdc/vim-template.git

Use of plugin

Now, you can make use of the templates when starting vim. For example, a python template is loaded by recognition of the *.py filename:

vim test.py

Or, if you have new buffer, type the following for the template to be loaded inside vim:

:Template py

The available templates can be seen here. Using the pathogen installation described above, these templates are located (on your machine) at ~/.vim/bundle/vim-template/templates/.

Customization

If you want to customize certain fields, like email and username, you can add the following to your .vimrc file:

" Customize the settings for vim-template plugin                                
let g:email = "desiredemail@gmail.com"
let g:user = "Desired Name"                                         
let g:license = "Desired License"

If you want to customize the templates, there is a search order for templates (see here) allowing you to write your own template-files and store them in the local directory.

Written by Chris S

November 7, 2013 at 7:28 pm

Posted in computing, Java, LaTeX, Python, R

Tagged with , , , ,

Install development version of scikit-learn

leave a comment »

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)

Again, substitute python with 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):

import sklearn

At this point you can dig into the documentation and examples available at the website.

Written by Chris S

November 6, 2013 at 8:24 pm