fengdu78 / Coursera-ML-AndrewNg-Notes

吴恩达老师的机器学习课程个人笔记
31.55k stars 10.57k forks source link

关于 ex2-logistic-regression 最后应该是 / 而不是 % 吧 #27

Open TensShinet opened 6 years ago

TensShinet commented 6 years ago

In [37]:

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)

结果一致 您看一下是否有问题呢 感谢您的无私帮助

WBYCHN commented 5 years ago

所以最后的正确率应该是66.1%,对不?