Machine learning on a Chromebook

Posted by German Rezzonico on Fri 07 April 2017

Machine learning on a Chromebook

Requirements

To set up a machine learning environment with Python 2.7.6 on a Chromebook Acer C720 with Ubuntu 14.04.5 LTS installed via crouton. The following Python libraries are required:

It is also required to have Jupyter Notebook installed to run and execute the code.

Instructions:

Install python 2.7, python-pip and python-dev

sudo apt-get install python2.7 python-pip python-dev

To verify that you have python and pip installed:

python --version
pip --version

Installing Ipython

sudo apt-get install ipython ipython-notebook

Installing Jupyter Notebook

-H, --set-home Request that the security policy set the HOME environment variable to the home directory specified by the target user's password database entry. Depending on the policy, this may be the default behavior.

sudo -H pip install jupyter

If any error --> Upgrade pip to the latest version

sudo -H pip install --upgrade pip

Try installing Jupyter again

sudo -H pip install jupyter

Running Jupyter Notebook

jupyter notebook

scipy, matplotlib, pandas and others

sudo apt-get install -f build-essential python-dev python-setuptools python-numpy python-numpy-dev python-scipy libatlas-dev libatlas3gf-base libfreetype6-dev libpng-dev g++ python-matplotlib python-pandas

seaborn

Download latest version of seaborn .tar.gz

tar -xzf seaborn-file.tar.gz
cd seaborn-path/
sudo python setup.py install

Using Jupyter Notebook

Automatically, Jupyter Notebook will show all of the files and folders in the directory it is run from.

To create a new notebook file, select New > Python 2 from the top right pull-down menu.

Alt jupyter new file

This will open a notebook. We can now run Python code in the cell or change the cell to markdown. For example, change the first cell to accept Markdown by clicking Cell > Cell Type > Markdown from the top navigation bar. We can now write notes using Markdown and even include equations written in LaTeX by putting them between the $$ symbols. For example, type the following into the cell after changing it to markdown:

# Simple Equation

Let us now implement the following equation:
$$ y = x^2$$

where $x = 2$

To turn the markdown into rich text, press CTRL+ENTER:

Alt jupyter markdown

You can use the markdown cells to make notes and document your code. Let's implement that simple equation and print the result. Select Insert > Insert Cell Below to insert and cell and enter the following code:

x = 2
y = x*x
print y

Alt jupyter run code