May-21-2018, 08:37 AM
Hi everyone, I am copying the below code out of a text book and am getting an error.
plt.subplot(221); plot_digits(X_aa[:25], images_per_row=5)
NameError: name 'plot_digits' is not defined
Can anyone help me solve this error?
Thanks
y_train_pred = cross_val_predict(sgd_clf, X_train_scaled, y_train, cv=3) conf_mx = confusion_matrix(y_train, y_train_pred) conf_mx plt.matshow(conf_mx, cmap=plt.cm.gray) plt.show() row_sums = conf_mx.sum(axis=1, keepdims=True) norm_conf_mx = conf_mx / row_sums np.fill_diagonal(norm_conf_mx, 0) plt.matshow(norm_conf_mx, cmap=plt.cm.gray) plt.show() cl_a, cl_b = 3, 5 X_aa = X_train[(y_train == cl_a) & (y_train_pred == cl_a)] X_ab = X_train[(y_train == cl_a) & (y_train_pred == cl_b)] X_ba = X_train[(y_train == cl_b) & (y_train_pred == cl_a)] X_bb = X_train[(y_train == cl_b) & (y_train_pred == cl_b)] plt.figure(figsize=(8,8)) plt.subplot(221); plot_digits(X_aa[:25], images_per_row=5) plt.subplot(222); plot_digits(X_ab[:25], images_per_row=5) plt.subplot(223); plot_digits(X_ba[:25], images_per_row=5) plt.subplot(224); plot_digits(X_bb[:25], images_per_row=5) plt.show()my error is:
plt.subplot(221); plot_digits(X_aa[:25], images_per_row=5)
NameError: name 'plot_digits' is not defined
Can anyone help me solve this error?
Thanks