machine-learning-book
machine-learning-book copied to clipboard
Chapter 13 : error with mlextend : TypeError: axis() got an unexpected keyword argument 'y_min'
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()
does this resolve the issue? where do you think i was making a mistake?
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.
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?