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 | |
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 | |
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
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
$ 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
import numpy as np | |
import matplotlib.pyplot as plt | |
from sklearn import tree | |
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.ensemble import RandomForestClassifier | |
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
3.944800674823166098e+00 | 4.996271186415386367e+00 | |
---|---|---|
5.547242838038199508e+00 | 5.414293869669647208e+00 | |
4.620646723315672943e+00 | 4.911930531086467155e+00 | |
4.846418245516238343e+00 | 3.584170537988319083e+00 | |
4.990222033288614689e+00 | 5.167624961159549279e+00 | |
5.832925679378353045e+00 | 6.730998187374821917e+00 | |
4.269651750644930743e+00 | 5.684499994023479275e+00 | |
6.382861274845375021e+00 | 5.195463145627869039e+00 | |
5.236782210357330491e+00 | 3.926700967069445269e+00 | |
4.672536804208451855e+00 | 4.868250521526301888e+00 |
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 svm | |
x1 = np.genfromtxt("class1.csv", delimiter = ",") | |
x2 = np.genfromtxt("class2.csv", delimiter = ",") | |
x3 = np.genfromtxt("class3.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.neighbors import KNeighborsClassifier | |
x1 = np.genfromtxt("class1.csv", delimiter = ",") | |
x2 = np.genfromtxt("class2.csv", delimiter = ",") | |
x3 = np.genfromtxt("class3.csv", delimiter = ",") | |
y1 = np.zeros(x1.shape[0]) | |
y2 = np.ones(x2.shape[0]) |