我有 22465 个测试文档,我将它们分类为 88 个不同的主题。我正在使用 predict_proba 来获得前 5 个预测主题。那么如何打印这 5 个主题的精度?
为了准确起见,这就是我正在做的事情:
model1 = LogisticRegression()
model1 = model1.fit(matrix, labels)
y_train_pred = model1.predict_log_proba(matrix_test)
order=np.argsort(y_train_pred, axis=1)
print(order[:,-5:]) #gives top 5 probabilities
n=model1.classes_[order[:, -5:]]
为了准确性
z=0
for x, y in zip(label_tmp_test, n):
if x in y:
z=z+1
print(z)
print(z/22465) #This gives me the accuracy by considering top 5 topics
如何以相同的方式找到前 5 个主题的精确度?Scikit 指标拒绝使用
q=model1.predict(mat_tmp_test)
print(metrics.precision_score(n, q))