Saturday, September 19, 2015

Python Sci-Kit ML env in Vagrant

0 lượt xem comment 0 comments

In this post i will show how we can have a machine learning environment with python and scikit-learn in Vagrant.

Python is a great language however use it in windows is hard because most of libraries might now work property so something is easier just provision a environment with Vagrant and them do it in Linux - thats what we goona do. This is pretty straight forward you just need to have vagrant installed and configured before we start.

Vagrant + Python + Scikit-Learn

So you just need have this Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "55.55.55.101"
config.vm.synced_folder ".", "/home/vagrant/shared/"
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install -y wget
sudo apt-get install -y curl
sudo apt-get install -y vim
sudo apt-get install -y git
sudo apt-get install -y build-essential
#
# Installs Python pip for python 2 and 3
#
sudo wget https://bootstrap.pypa.io/get-pip.py
sudo python2 get-pip.py
sudo python3 get-pip.py
#
# Install Python Machine Learning: scikit-learn
#
sudo apt-get install -y python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose
sudo apt-get install -y build-essential python3-dev python3-setuptools python3-numpy python3-scipy libatlas-dev libatlas3gf-base
sudo pip3 install -U scikit-learn
SHELL
end
view raw Vagrantfile hosted with ❤ by GitHub
As you can see we are installing pip for python 2 and python 3. Once you download my Vagrant file you just need do a $ vagrant up

This could take some time because there are lots of libraries and dependencies. After the provisioning you can enter on the box via ssh doing $ vagrant ssh

IF you want to test your scikit-learn you can create this python script inside your vagrant linux.

from sklearn import datasets
iris = datasets.load_iris()
digits = datasets.load_digits()
print(digits.data)
view raw sci.py hosted with ❤ by GitHub
Likewise RStudio scikit-Learn comes with some datasets like iris. You can run this code now. You might be interested in plotting them you can copy the commands to install sci-kit and install into a virtual box instance of Ubuntu in order to have graphical interface. That`s it, Have fun :-) Cheers, Diego Pacheco
Tags: update, script, code,

comment 0 comments

Chuyên mục văn hoá giải trí của VnExpress

.

© 2017 www.blogthuthuatwin10.com

Tầng 5, Tòa nhà FPT Cầu Giấy, phố Duy Tân, Phường Dịch Vọng Hậu, Quận Cầu Giấy, Hà Nội
Email: nguyenanhtuan2401@gmail.com
Điện thoại: 0908 562 750 ext 4548; Liên hệ quảng cáo: 4567.