Open mhnlp opened 5 years ago
Hi there,
you are right. The issue comes from the fact that the plot_decision_region
function expects class labels {0, 1, ...} whereas the class labels for the perceptron are {-1, 1}. I.e., do make it work, the following lines of the perceptron need to changed:
def predict(self, X):
return np.where(self.net_input(X) >= 0.0, 1, -1)
to
def predict(self, X):
return np.where(self.net_input(X) >= 0.5, 1, 0)
and
y = np.where(y == 'Iris-setosa', -1, 1)
to
y = np.where(y == 'Iris-setosa', 0, 1)
I think we should see if the plot_decision_regions
can be "fixed" to support arbitrary class labels.
This code comes from this post
mlxtend.version: '0.14.0' reproduced 100% on https://colab.research.google.com
Expected: plot a figure with 2 colored region
Actual: plot_decision_regions is missing the color of bottom region