def plot_fit(self):
"""Plot the training data in X array along with decision boundary
"""
from matplotlib import pyplot as plt
x1 = np.linspace(self.table.min(), self.table.max(), 100)
#reverse self.theta as it requires coeffs from highest degree to constant term
x2 = np.polyval(np.poly1d(self.theta[::-1]),x1)
plt.plot(x1, x2, color='r', label='decision boundary');
plt.scatter(self.X[:, 1], self.X[:, 2], s=40, c=self.y, cmap=plt.cm.Spectral)
plt.legend()
plt.show()
评论列表
文章目录