我从“Python机器学习入门”一书中学习Python
在这本书中,使用了下面的功能。
但我不明白参数“X”是如何工作的,以及参数"eps“的必要性。
你能帮帮我吗?
def plot_2d_classification(classifier, X, fill=False, ax=None, eps=None,
alpha=1, cm=cm3):
# multiclass
if eps is None:
eps = X.std() / 2.
if ax is None:
ax = plt.gca()
x_min, x_max = X[:, 0].min() - eps, X[:, 0].max() + eps
y_min, y_max = X[:, 1].min() - eps, X[:, 1].max() + eps
xx = np.linspace(x_min, x_max, 1000)
yy = np.linspace(y_min, y_max, 1000)
X1, X2 = np.meshgrid(xx, yy)
X_grid = np.c_[X1.ravel(), X2.ravel()]
decision_values = classifier.predict(X_grid)
ax.imshow(decision_values.reshape(X1.shape), extent=(x_min, x_max,
y_min, y_max),
aspect='auto', origin='lower', alpha=alpha, cmap=cm)
ax.set_xlim(x_min, x_max)
ax.set_ylim(y_min, y_max)
ax.set_xticks(())
ax.set_yticks(())发布于 2022-08-23 12:34:16
我认为每股收益是每平方的一个元素。它决定了数据整体的紧凑性。当您继续增加eps的值时,您的所有数据点都会聚成一个点。
https://stackoverflow.com/questions/67847651
复制相似问题