print(__doc__)
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier
# Parameters
n_classes = 3
plot_colors = “ryb”
plot_step = 0.02
# Load data
iris = load_iris()
print (iris.data)
print (iris.data[:, [0, 1]])
#print (iris.data[:, [1, 2]])
for pairidx, pair in enumerate([[0, 1], [0, 2], [0, 3],
[1, 2], [1, 3], [2, 3]]):
# [0,1,2,3,4]从四列数据中选取2个要素进行训练
X = iris.data[:, pair]
y = iris.target
# Train
clf = DecisionTreeClassifier().fit(X, y)
# 2行3列排列图片
plt.subplot(2, 3, pairidx + 1)
#第一列
x_min, x_max = X[:, 0].min() – 1, X[:, 0].max() + 1
print (x_min,x_max)
#第二列
y_min, y_max = X[:, 1].min(