如何列出测试集中预测错误的行?

时间:2018-05-17 11:36:00

标签: scikit-learn

我们使用这样的代码来衡量准确性,但我想检查哪些行预测是错误的。我该怎么办呢?

text_mnb_lemmatized = Pipeline([('vect', lemma_count_vect), 
                                ('tfidf', TfidfTransformer(sublinear_tf=True, use_idf=False)), 
                             ('mnb', MultinomialNB(alpha=0.1, fit_prior=True))])

text_mnb_lemmatized = text_mnb_lemmatized.fit(train_data['CDESCR'], train_data['COMPID'])

predicted_mnb_lemmatized = text_mnb_lemmatized.predict(test_data['CDESCR'])

np.mean(predicted_mnb_lemmatized == test_data['COMPID'])

1 个答案:

答案 0 :(得分:2)

假设test_data是Pandas DataFrame:

test_data[predicted_mnb_lemmatized != test_data['COMPID']]