Open vasili111 opened 1 year ago
Also cell 6 with code:
# extra code – this cell generates and saves Figure 5–2
from sklearn.preprocessing import StandardScaler
Xs = np.array([[1, 50], [5, 20], [3, 80], [5, 60]]).astype(np.float64)
ys = np.array([0, 0, 1, 1])
svm_clf = SVC(kernel="linear", C=100).fit(Xs, ys)
scaler = StandardScaler()
X_scaled = scaler.fit_transform(Xs)
svm_clf_scaled = SVC(kernel="linear", C=100).fit(X_scaled, ys)
plt.figure(figsize=(9, 2.7))
plt.subplot(121)
plt.plot(Xs[:, 0][ys==1], Xs[:, 1][ys==1], "bo")
plt.plot(Xs[:, 0][ys==0], Xs[:, 1][ys==0], "ms")
plot_svc_decision_boundary(svm_clf, 0, 6)
plt.xlabel("$x_0$")
plt.ylabel("$x_1$ ", rotation=0)
plt.title("Unscaled")
plt.axis([0, 6, 0, 90])
plt.grid()
plt.subplot(122)
plt.plot(X_scaled[:, 0][ys==1], X_scaled[:, 1][ys==1], "bo")
plt.plot(X_scaled[:, 0][ys==0], X_scaled[:, 1][ys==0], "ms")
plot_svc_decision_boundary(svm_clf_scaled, -2, 2)
plt.xlabel("$x'_0$")
plt.ylabel("$x'_1$ ", rotation=0)
plt.title("Scaled")
plt.axis([-2, 2, -2, 2])
plt.grid()
save_fig("sensitivity_to_feature_scales_plot")
plt.show()
gives this error:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[6], line 17
15 plt.plot(Xs[:, 0][ys==1], Xs[:, 1][ys==1], "bo")
16 plt.plot(Xs[:, 0][ys==0], Xs[:, 1][ys==0], "ms")
---> 17 plot_svc_decision_boundary(svm_clf, 0, 6)
18 plt.xlabel("$x_0$")
19 plt.ylabel("$x_1$ ", rotation=0)
NameError: name 'plot_svc_decision_boundary' is not defined
Similar error is recived when running cells: 7 and 11.
I am running cells from top till cell 5 and when running cell 5 with this code:
I am getting error:
How to fix it?