This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo apt-get install graphviz | |
$ dot -T png -o decisiontree_simple.png decisiontree_simple.graphviz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data | |
上記にあるデータをiris.dataとして保存 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from sklearn.naive_bayes import GaussianNB | |
x1 = np.genfromtxt("class1.csv", delimiter = ",") | |
x2 = np.genfromtxt("class2.csv", delimiter = ",") | |
y1 = np.zeros(x1.shape[0]) | |
y2 = np.ones(x2.shape[0]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from sklearn import naive_bayes | |
x = np.genfromtxt("source.csv", delimiter=",") | |
plt.scatter(x[:,0], x[:,1]) | |
plt.savefig("readfromtxt.png") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sklearn import linear_model | |
import matplotlib.pyplot as plt | |
X = np.array([[0, 0, 1], [1, 1, 2], [2, 2, 3], [3, 3, 3.1]]) | |
Y = np.array([0.1, 1.1, 1.8, 2.7]) | |
regr = linear_model.LinearRegression() | |
regr.fit(X, Y) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sklearn import linear_model | |
import matplotlib.pyplot as plt | |
array = np.array([[0, 0.1], [1, 1.1], [2, 1.8], [3, 2.7]]) | |
print array | |
X = array[:, 0:1] | |
Y = array[:, 1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sklearn import linear_model | |
import matplotlib.pyplot as plt | |
X = np.array([[0], [1], [2], [3]]) | |
Y = np.array([0.1, 1.1, 1.8, 2.7]) | |
regr = linear_model.LinearRegression() | |
regr.fit(X, Y) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Irisデータセットの取得 | |
Shellから | |
$ wget http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data | |
GUIから | |
ブラウザで http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data を開き、データをダウンロード |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ source virtualenvwrapper.sh | |
$ lsvirtualenv | |
bootcamp1 | |
$ workon bootcamp1 | |
(bootcamp1)$ lssitepackages | |
dateutil pylab.pyc | |
easy-install.pth pytz | |
matplotlib scikit_learn-0.12-py2.7.egg-info | |
matplotlib-1.1.1-py2.7.egg-info scipy | |
mpl_toolkits scipy-0.11.0-py2.7.egg-info |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
if __name__ == '__main__': | |
print sys.argv |