Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 13 : error with mlextend : TypeError: axis() got an unexpected keyword argument 'y_min' #127

Open
andysingal opened this issue May 12, 2023 · 4 comments

Comments

@andysingal
Copy link

Screenshot 2023-05-12 at 9 21 35 PM Screenshot 2023-05-12 at 9 21 45 PM Hi Sebastian, while working on mlextend plot as shared i am getting an error. Can you please assist to resolve this issue. Thanks, Ankush Singal
@Asjad22
Copy link

Asjad22 commented May 12, 2023

loss_fn = nn.BCELoss()
optimizer = torch.optim.SGD(model.parameters(), lr=0.015)
history = train(model, num_epochs, train_dl, x_valid, y_valid)

from mlxtend.plotting import plot_decision_regions

fig = plt.figure(figsize=(16, 4))
ax = fig.add_subplot(1, 3, 1)
plt.plot(history[0], lw=4)
plt.plot(history[1], lw=4)
plt.legend(['Train loss', 'Validation loss'], fontsize=15)
ax.set_xlabel('Epochs', size=15)

ax = fig.add_subplot(1, 3, 2)
plt.plot(history[2], lw=4)
plt.plot(history[3], lw=4)
plt.legend(['Train acc.', 'Validation acc.'], fontsize=15)
ax.set_xlabel('Epochs', size=15)

ax = fig.add_subplot(1, 3, 3)
plot_decision_regions(X=x_valid.numpy(), 
                      y=y_valid.numpy().astype(np.int64),
                      clf=model)
ax.set_xlabel(r'$x_1$', size=15)
ax.xaxis.set_label_coords(1, -0.025)
ax.set_ylabel(r'$x_2$', size=15)
ax.yaxis.set_label_coords(-0.025, 1)

#plt.savefig('figures/13_05.png', dpi=300)
plt.show()

@andysingal
Copy link
Author

does this resolve the issue? where do you think i was making a mistake?

@Asjad22
Copy link

Asjad22 commented May 15, 2023

i guess you're getting the error because of these variables you defined.
loss_hist_train and loss_hist_valid, accuracy_hist_train and accuracy_hist_valid.

try running the code as is mentioned in the repository. i did the same and it's working fine with me.

@rasbt
Copy link
Owner

rasbt commented May 15, 2023

Thanks for the note and sorry about the hassle. Glad you solved this though!

Just to make a note so that it can be fixed in future updates: Was there a mismatch between book text and repo code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants