Build a machine learning scikit-learn environment with VirtualBox and Ubuntu

VirtualBox installation

Download the installer for your environment from the URL below and install it. https://www.virtualbox.org

Also download the "Oracle VM VirtualBox Extension Pack" and run it after installing VirtualBox to install it.

Create an Ubuntu virtual machine

Download the virtual hard disk image from the following URL and extract the Zip file. https://www.ubuntulinux.jp/download/ja-remix-vhd

Start VirtualBox and create a new virtual machine with "New (N)". * See the above URL.

When the virtual machine name is set, the following folders are created in the home directory, so save the virtual hard disk image in the target folder.

[Example] When the virtual machine name is "Ubuntu"

Windows


[Home directory]¥VirtualBox VMs¥Ubuntu¥

Mac/Linux


~/VirtualBox VMs/Ubuntu/

By the way, I set the main memory to 4GB.

After setting, start the virtual machine and perform the initial settings.

Ssh connection settings

If you want to operate the virtual machine with SSH connection instead of directly operating it, follow the steps below.

After the initial settings are completed and the desktop is displayed, execute the following command so that you can connect to the virtual machine by SSH.

$ sudo apt-get install openssh-server

After execution, shut down the virtual machine and change the VirtualBox network setting from "NAT" to "Bridge Adapter". This allows an SSH connection to the virtual machine's IP address.

$ ssh [username]@[IP address]

Building a python3 environment with pyenv

Please refer to the following site. http://qiita.com/akito1986/items/be5dcd1a502aaf22010b

Installation of required packages

Install the packages required to install pyenv.

$ sudo apt-get install git gcc make openssl libssl-dev libbz2-dev libreadline-dev libsqlite3-dev

Install pyenv

Execute the following command.

$ cd /usr/local/
$ sudo git clone git://github.com/yyuu/pyenv.git ./pyenv
$ sudo mkdir -p ./pyenv/versions ./pyenv/shims
$ cd /usr/local/pyenv/plugins/
$ sudo git clone git://github.com/yyuu/pyenv-virtualenv.git

Create a PATH configuration file.

$ echo 'export PYENV_ROOT="/usr/local/pyenv"' | sudo tee -a /etc/profile.d/pyenv.sh
$ echo 'export PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}"' | sudo tee -a /etc/profile.d/pyenv.sh
$ source /etc/profile.d/pyenv.sh

Operation check.

$ pyenv --version

PATH setting for sudo

$ sudo visudo

Edit as follows.

#Change
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
↓
# Defaults  secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

#add to
Defaults    env_keep += "PATH"
Defaults    env_keep += "PYENV_ROOT"

Installation of python3 (no implementation required)

Execute the following command

$ sudo pyenv install -v 3.5.1

Confirmation after installation.

$ pyenv versions
* system (set by /usr/local/pyenv/version)
  3.5.1

Change the default version.

$ sudo pyenv global 3.5.1

Confirmation of change result.

$ pyenv versions
  system
* 3.5.1 (set by /usr/local/pyenv/version)
$ python --version
Python 3.5.1

In addition, 3.5.1 is the latest version as of April 12, 2016.

Miniconda installation

Please refer to the following site. http://qiita.com/icoxfog417/items/950b8af9100b64c0d8f9

Execute the following command.

$ sudo pyenv install miniconda3-3.19.0
$ sudo pyenv global miniconda3-3.19.0

Check the execution result.

$ pyenv versions
  system
  3.5.1 (set by /usr/local/pyenv/version)
* miniconda3-3.19.0 (set by /usr/local/pyenv/version)
$ python --version
Python 3.5.1 :: Continuum Analytics, Inc.

Building a virtual environment for machine learning

Execute the following command.

$ conda create -n ml_env numpy scipy scikit-learn matplotlib cython ipython python-notebook
$ source ./.conda/envs/ml_env/bin/activate ml_env
(ml_env)$

Operation check

See the tutorial on the official website. http://scikit-learn.org/stable/tutorial/basic/tutorial.html

Load and display the sample dataset.

$ python
>>> from sklearn import datasets
>>> iris = datasets.load_iris()
>>> digits = datasets.load_digits()
>>> print(digits.data)  
[[  0.   0.   5. ...,   0.   0.   0.]
 [  0.   0.   0. ...,  10.   0.   0.]
 [  0.   0.   0. ...,  16.   9.   0.]
 ...,
 [  0.   0.   1. ...,   6.   0.   0.]
 [  0.   0.   2. ...,  12.   0.   0.]
 [  0.   0.  10. ...,  12.   1.   0.]]

If it is output as above, OK!

The problem is what to do from now on ... (sweat)

Recommended Posts

Build a machine learning scikit-learn environment with VirtualBox and Ubuntu
Build a machine learning environment
Build a Python machine learning environment with a container
Build a machine learning application development environment with Python
Build AI / machine learning environment with Python
Build a virtual environment with pyenv and venv
Build python3 environment with ubuntu 16.04
Build a python virtual environment with virtualenv and virtualenvwrapper
Build a machine learning Python environment on Mac OS
Easy machine learning with scikit-learn and flask ✕ Web app
Build a python virtual environment with virtualenv and virtualenvwrapper
Practical machine learning with Scikit-Learn and TensorFlow-TensorFlow gave up-
Create a machine learning environment from scratch with Winsows 10
Build a machine learning environment natively on Windows 10 (x64)
Build a numerical calculation environment with pyenv and miniconda3
Build a python machine learning study environment on macOS sierra
Build a machine learning environment on mac (pyenv, deeplearning, opencv)
Build a machine learning environment using PyCharm on Ubuntu environment (TensorFlow will also be introduced!)
(Now) Build a GPU Deep Learning environment with GeForce GTX 960
Try machine learning with scikit-learn SVM
Until you create a machine learning environment with Python on Windows 7 and run it
Build a PyData environment for a machine learning study session (January 2017)
How to build Anaconda virtual environment used in Azure Machine Learning and link with Jupyter
How to interactively draw a machine learning pipeline with scikit-learn and save it in HTML
Build a 64-bit Python 2.7 environment with TDM-GCC and MinGW-w64 on Windows 7
Building a Windows 7 environment for getting started with machine learning with Python
Build a Python environment on your Mac with Anaconda and PyCharm
[Reading Notes] Hands-on Machine Learning with Scikit-Learn, Keras, and TensorFlow Chapter 1
[DynamoDB] [Docker] Build a development environment for DynamoDB and Django with docker-compose
Easily build a development environment with Laragon
Build Python3 and OpenCV environment on Ubuntu 18.04
Build a Tensorflow environment with Raspberry Pi [2020]
A story about machine learning with Kyasuket
Build a Fast API environment with docker-compose
Python and machine learning environment construction (macOS)
[Linux] Build a jenkins environment with Docker
Build a python virtual environment with pyenv
Build a capture acquisition machine with Selenium
Build a modern Python environment with Neovim
Creating a development environment for machine learning
[Linux] Build a Docker environment with Amazon Linux 2
A story about automating online mahjong (Mahjong Soul) with OpenCV and machine learning
Build a CentOS Linux 8 environment with Docker and start Apache HTTP Server
Quickly build a python environment for deep learning and data science (Windows)
Build a drone simulator environment and try a simple flight with Mission Planner
Building a machine learning environment with Tellus GPU server (Sakura high-power computing)
Steps to build a Django environment with Win10 WSL Ubuntu18.04 + Anaconda + Apache2
Build a WardPress environment on AWS with pulumi
Build python environment with pyenv on EC2 (ubuntu)
Building a python environment with virtualenv and direnv
Build a python environment with ansible on centos6
[Python] Build a Django development environment with Docker
Create a python3 build environment with Sublime Text3
Build a Django environment with Vagrant in 5 minutes
[Memo] Build a virtual environment with Pyenv + anaconda
Build a Django development environment with Doker Toolbox
Build a Kubernetes environment for development on Ubuntu
Build a Python environment with OSX El capitan
Quickly build a Python Django environment with IntelliJ
Build PyPy and Python execution environment with Docker
Build a python execution environment with VS Code