I was trying to calculate the accuracy of my roberta label and pre existing dataset label

enter image description here

enter image description here

i was confused on how to operate pandas's value_counts(), i dont know how to do operations on it before, the error says it needs identical series, but the label is already mapped the same

7 Replies 7

It appears to be an issue caused by the different order of the index. use following code instead ==

y_true.eq(y_pred)

Please don't post pictures of text. Instead, copy the text itself, [edit] it into your post, and use the formatting tools like code formatting.

Ideally, make a good reproducible pandas example and post that.

@Panda-Kim Shouldn't they automatically align? Maybe there are actually trailing spaces... Hard to tell without an example (see my reply above).

And isn't .eq() just the method form of ==? Why would it behave any differently?

@wjandrea

First, the results of value_count are sorted by the size of the values, not by their names. This can be confirmed in the image of this post.

Second, == and eq are not entirely the same. It should be easy to verify this by creating an example of series.

@Panda-Kim I stand corrected! I was thinking of how math operations like + automatically align regardless of order, but apparently comparisons like == don't do that. I'm not sure what the rationale is. Using the method version like .eq() does in fact get around that.

you could create minal example data so we could use it for tests.

Is this not the classical case of a confusion matrix? Confusion_matrix is the basic concept of machine learning, where you comparing the predictions with the actual values. The ouput compares the values of both series.

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.