Additional setup
The next part will focus on image processing and manipulation. This requires some extra libraries you may not have. At this point, it may make sense to just install all the typical packages required in scientific computing, which can be done as follows:
sudo apt-get install python-numpy python-scipy python-matplotlib
ipython ipython-notebook python-pandas python-sympy python-nose
Additionally, install the image processing library, some external matrix mathematics libraries, and underlying requirements, which can be done as follows:
sudo pip install ndimagesudo apt-get install libatlas3-base-dev gcc gfortran g++
Converting images to matrices
Much of machine learning is just operations on matrices. We will start that process next by converting our images into a series of matrices—essentially, a 3D matrix as wide as the number of images we have.
Almost all matrix operations that we will perform in this chapter, and the entire book, use NumPy—the most popular scientific computing...