juliano.net
juliano.net

Reputation: 8177

How can I list the rows in the test set that were predicted wrong?

We use a code like this to measure the accuracy, but I wanted to check which rows predictions were wrong. How can I do such thing?

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'])

Upvotes: 0

Views: 19

Answers (1)

MaxU - stand with Ukraine
MaxU - stand with Ukraine

Reputation: 210942

assuming test_data is a Pandas DataFrame:

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

Upvotes: 2

Related Questions