Python でデータ分析や機械学習をするために多数のライブラリが使われるが、私は別に環境構築を頑張りたいわけではない。 ありがたいことに、Continuum Analytics というデータ分析企業が、 Anaconda というパッケージにまとめて公開してくださっている。 また近年の開発環境は Docker のイメージで簡単に取得できることが多く、Anaconda でも Docker イメージがあるようなので使ってみる。
Pull自体は簡単。Docker ありがたや。
$ sudo docker pull continuumio/anaconda Using default tag: latest latest: Pulling from continuumio/anaconda a3ed95caeb02: Pull complete 79362e2488a1: Pull complete 045baf0ccb0b: Pull complete 42c3e6650b1b: Pull complete 8142985a9482: Pull complete Digest: sha256:bf71d93db763521cfbc21b6e2e008447a3dab81cc1060757fd661b0fbc2fee7e Status: Downloaded newer image for continuumio/anaconda:latest
イメージサイズはそれなりに大きい。
$ sudo docker images REPOSITORY TAG IMAGE ID CREATED SIZE continuumio/anaconda latest d8b2ca6ebc3d 7 weeks ago 1.825 GB
ブラウザで動くインタラクティブでグラフィカルな Python 実行環境、Jupyter (IPython notebook) を使ってみる。 ホームディレクトリに notebooks ディレクトリを作り、そこに実行結果等を保存していくことにする。
$ cd ~ $ mkdir notebooks $ docker run -it -v `pwd`/notebooks:/notebooks -w /notebooks -p 8888:8888 continuumio/anaconda jupyter notebook --ip=172.17.0.2 --no-browser
あとは、ローカルで Docker を動かしているなら、 http://localhost:8888 を見ると Jupyter の画面が開くはず。
リモートで Docker を動かしているなら、SSHのローカルポートフォワーディングで "-L8888:localhost:8888" とかやってリモートホストに接続して、ローカルのブラウザで http://localhost:8888 を開くと使えるはず。
-
【世界で2万人が受講】実践 Python データサイエンス Anacondaについてはこちらで知った。
-
Download Anaconda now! | Continuum Anacondaダウンロードサイト。Win/Mac/Lin用のインストーラがダウンロードできる。
-
continuumio/anaconda Anaconda Docker でググったらこちらが出たので使わせて頂いた。
-
機械学習のためのPythonの基礎「NumPy」を学ぶ - learning.ikeay.net NumPyはこちらでも取り上げられていた。100 numpy exercises やってみたい。