def quiz15():
X, Y, N = read_file("features.train")
Y_0 = (Y == 0).astype(int)
c_l = []
w_l = []
for i in range(-6, 4, 2):
c = 10 ** i
c_l.append(c)
clf = svm.SVC(C=c, kernel='linear', shrinking=False)
clf.fit(X, Y_0)
w = clf.coef_.flatten()
norm_w = np.linalg.norm(w, ord=2)
w_l.append(norm_w)
print("C = ", c, ' norm(w) =', norm_w)
plt.semilogx(c_l, w_l)
plt.savefig("h5_q15.png", dpi=300)
评论列表
文章目录