machine-learning-book icon indicating copy to clipboard operation
machine-learning-book copied to clipboard

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

Open andysingal opened this issue 1 year ago • 4 comments

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

andysingal avatar May 12 '23 15:05 andysingal

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()

Asjad22 avatar May 12 '23 16:05 Asjad22

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

andysingal avatar May 15 '23 03:05 andysingal

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.

Asjad22 avatar May 15 '23 07:05 Asjad22

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?

rasbt avatar May 15 '23 12:05 rasbt