theta_min = np.matrix(result2[0])
predictions = predict(theta_min, X2)
correct = [1 if ((a == 1 and b == 1) or (a == 0 and b == 0)) else 0 for (a, b) in zip(predictions, y2)]
accuracy = (sum(map(int, correct)) % len(correct))
print ('accuracy = `{0}%'.format(accuracy))
在第四行的 len(correct) 的前面 % 应该是 /
而且 我用 / 的时候 与您之后的
model = linear_model.LogisticRegression(penalty='l2', C=1.0)
model.fit(X2, y2.ravel())
model.score(X2, y2)
In [37]:
在第四行的 len(correct) 的前面 % 应该是 / 而且 我用 / 的时候 与您之后的
结果一致 您看一下是否有问题呢 感谢您的无私帮助