-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improving the confusionMatrix function #136
Conversation
Catchup for trim
Catchup to upstream
Catchup to upstream
You should add a test for when the levels are the same and for when they are different. Other than that, it looks like a good idea to me! — On Mon, Apr 6, 2015 at 6:30 AM, Coveralls notifications@github.com
|
Test added. It also makes sure that if the levels are different, a warning is issued, but the results are the same as if they were not out of order. |
Actually, on second thought, don't merge this quite yet. This fails if the data has fewer levels than the reference class (i.e. the predictions coming in are only of 1 class, all predicted to be the prevalent class). While this is unhelpful, it should still make a confusion matrix -- no reason not to. I'll work on how to normalize this next. |
Not sure why this is happening now:
|
Some cases to consider:
Not sure what the story is with |
@topepo Yes, I just encountered both of those issues in my own testing -- I will add them to the function and add unit tests to ensure they function correctly. The |
Thanks, Max |
Improving the confusionMatrix function
One issue I have had with the
confusionMatrix
command is that if the factor levels are identical, but out of order, the function fails. The following MWE gives an example of the problem.There is no reason that the function cannot recognize the levels being the same and reorder them. This patch does that, and issues a warning to the user letting them know that the reference has been reordered. Alternatively, it could be modified so that the data is reordered and a warning is issued. In any case, the new function will produce a confusion matrix that is identical in metrics to the correct matrix above, but with the table inverted.