Skip to content

Instantly share code, notes, and snippets.

@masayuki5160
Last active February 19, 2017 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masayuki5160/6ab3006bff0e398b1c92ed0f9ded4aee to your computer and use it in GitHub Desktop.
Save masayuki5160/6ab3006bff0e398b1c92ed0f9ded4aee to your computer and use it in GitHub Desktop.
setup scikit-learn on ubuntu14.04

scikit-learn

env

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.5 LTS"

setup command

sudo apt-get update
sudo apt-get -y install python-pip
sudo apt-get install build-essential python-dev python-setuptools python-numpy python-scipy libatlas-dev libatlas3gf-base
sudo pip install scikit-learn
sudo pip install pandas

test

$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sklearn
>>> sklearn.__version__

result

$ python xor-train.py
('score = ', 1.0)

appendix

scikit-learnのインストール in Ubuntu http://www.iandprogram.net/entry/2015/09/15/221518

import pandas as pd
from sklearn import svm, metrics
# XOR result
xor_input = [
[0,0,0],
[0,1,1],
[1,0,1],
[1,1,0],
]
# split input data to training data and test data
xor_df = pd.DataFrame(xor_input)
xor_data = xor_df.ix[:,0:1]
xor_label = xor_df.ix[:,2]
# learning
clf = svm.SVC()
clf.fit(xor_data, xor_label)
pre = clf.predict(xor_data)
# evaluation
ac_score = metrics.accuracy_score(xor_label, pre)
print("score = ", ac_score)
@masayuki5160
Copy link
Author

GCPにて実施

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment