MLmetrics
MLmetrics copied to clipboard
Added support for micro/macro averages multi-class classification metrics
Just added support for multi-class classification metrics such as:
- Precision (micro and macro averages)
- Recall (micro and macro averages)
- F1 Score (micro and macro averages)
As described for instance here. This is directly related with the enhancement I've requested in #2
Hope everything is ok, first time editing an R package. Also there might be a bug (or is it expected?) with Confusion_DF/Precision/Recall when the positive label is missing from the predicted labels.
Added a small optimization to classification metrics. Based on this http://stackoverflow.com/questions/27303534/faster-way-to-subset-on-rows-of-a-data-frame-in-r
It still made some difference in my tests:
Unit: milliseconds
expr min lq mean median uq max neval
PRECISION 2.454476 2.913534 3.102103 3.052503 3.188008 12.70121 1000
PRECISION_OPT 1.869344 2.271045 2.431992 2.373443 2.470644 12.88946 1000
P_MICRO 4.902790 5.571457 5.937313 5.819753 6.042065 15.27695 1000
P_MICRO_OPT 2.521458 2.976474 3.184339 3.109862 3.228235 12.64501 1000
@yanyachen Hi, I'm interested in the functionality that this PR adds. Can you review this pull request and merge it? If necessary, I can help with validating the code, or adding few tests.