def evaluation(self, theta, X_test, y_test):
theta = theta[:, :-1]
M, n_test = theta.shape[0], len(y_test)
prob = np.zeros([n_test, M])
for t in range(M):
coff = np.multiply(y_test, np.sum(-1 * np.multiply(nm.repmat(theta[t, :], n_test, 1), X_test), axis=1))
prob[:, t] = np.divide(np.ones(n_test), (1 + np.exp(coff)))
prob = np.mean(prob, axis=1)
acc = np.mean(prob > 0.5)
llh = np.mean(np.log(prob))
return [acc, llh]
bayesian_logistic_regression.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录