決定木#
回帰木#
回帰木(regression tree)は特徴空間を
ここで
import numpy as np
import matplotlib.pyplot as plt
n = 10
np.random.seed(0)
# class 0
y0 = np.zeros(shape=(n//2, ))
x0 = np.random.normal(loc=(-1, -1), scale=0.8, size=(n//2, 2))
# class 1
y1 = np.ones(shape=(n//2, ))
x1 = np.random.normal(loc=(1, 1), scale=0.8, size=(n//2, 2))
y = np.append(y0, y1)
X = np.append(x0, x1, axis=0)
fig, ax = plt.subplots()
ax.scatter(X[(y == 0), 0], X[(y == 0), 1], label="y = 0")
ax.scatter(X[(y == 1), 0], X[(y == 1), 1], label="y = 1")
ax.legend()
ax.set(xlabel="x1", ylabel="x2")
fig.show()

for x in X[:, 0]:
x