基于此示例:http://scikit-learn.org/stable/auto_examples/classification/plot_lda_qda.html
我试图在我的一张LDA图上绘制轮廓。
以下是我用于绘图部分的代码:
# Get the limits of the graph. Used for adapted color areas
x_min, x_max = fig.axes[0].get_xlim()
y_min, y_max = fig.axes[0].get_ylim()
# Fit the LDA classifier on the new subspace
lda.fit(transformed, analytes)
# Step size of the mesh. Decrease to increase the quality of the VQ.
# point in the mesh [x_min, m_max]x[y_min, y_max].
# h = 0.02
h = 0.005
# Plot the decision boundary. For that, we will assign a color to each
xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))
# Predict the class for each point of the space
Z = lda.predict(np.c_[xx.ravel(), yy.ravel()])
Z = Z.reshape(xx.shape)
# Plot the areas
plt.imshow(Z, extent=(x_min, x_max, y_min, y_max),
cmap=cmap, aspect='auto', origin='lower', alpha=0.7)
plt.contour(xx, yy, Z, colors='k')
plt.show()
有效。大多。由于未知原因,某些轮廓未绘制:
正如您在底部所看到的,绿色区域和蓝色区域之间没有分隔线。
你知道为什么吗?