-
Notifications
You must be signed in to change notification settings - Fork 876
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
Created new per class accuracy function. #624
Conversation
Features: * new pos_label argument(got to change name, as there could be ambiguity with positive_label in the original scoring function). Is None by default, in which case, average accuracy is returned * uses existing _accuracy function for computing per class accuracy
Hello @deepandas11! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2019-11-22 19:01:42 UTC |
@@ -111,10 +120,10 @@ def scoring(y_target, y_predicted, metric='error', | |||
elif metric == 'error': | |||
res = _error(targ_tmp, pred_tmp) | |||
elif metric == 'average per-class accuracy': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there was a misunderstanding. The per-class accuracy would not be used to replace the average-per-class-accuracy. Maybe have a look at the brief comment in #615
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! This discussion makes it much clearer now. Thanks!
Hello, @rasbt ! |
pos_label : str or int, None by default. | ||
The class whose accuracy score is to be reported. | ||
'binary' has to be set to True. | ||
binary : bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if binary
is set to False
. Will this be a regular accuracy computation then? I think it looks like that. It would be nice to document that.
I have another suggestion, though. How about
- calling this function just "accuracy" and computing the "average" per-class accuracy as an option?
E.g., instead of binary
, we could use another parameter called method
.
method='standard'
computes the regular accuracymethod='binary'
computes per-class accuracy for the positive classmethod='average'
computes average per class accuracy similar to https://github.com/rasbt/mlxtend/blob/master/mlxtend/evaluate/scoring.py#L113
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that should have been documented. Thanks for pointing that out.
As for the suggestion, I think if you are looking to introduce modularity with respect to the individual metrics in "scoring.py", this would be a good first step.
However, it would be interesting to know if you indeed want to eventually deprecate the current methodology of finding metrics and move towards standalone functions, like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to support both, like scikit-learn does. The 'string' arguments in scoring are useful as a short-cut. However, it doesn't allow options like pos_label
. Inside scoring, the idea would then be to use the per_class_accuracy
function to implement the current 'average per-class accuracy'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, implementation-wise, I think the API would be less confusing if we have just a single accuracy function that can compute the three types of metrics, based on the choice of "method". This however, means no separate per_class_accuracy method, as was originally intended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I think it's best if we call it just classification_accuracy
? And then inside we have the "per class"
option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have to correct this, "accuracy_score
" may be better because we also have lift_score
already, and it is generally more consistent with sklearn then.
Sorry, it was a busy week and just got a chance to look at it. I have a suggestion (mention in the comment above). Let me know what you think. Also, it's weird that the unit test for Windows fails. Not sure if this is necessarily related to this PR or a general issue. Will investigate. |
Features: * new pos_label argument(got to change name, as there could be ambiguity with positive_label in the original scoring function). Is None by default, in which case, average accuracy is returned * uses existing _accuracy function for computing per class accuracy
This reverts commit 4ee5d6a.
4982353
to
d8abfcd
Compare
Just did a rebase of your changes on top of the master branch to resolve the CI issues. You would need to do a
on your end before making any additional changes. |
…lxtend into per_class_accuracy
Thank you so much for resolving the CI issue. |
Function capable of finding different kinds of accuracy metrics in three different 'method' modes.
So, I have made the changes as discussed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the changes. It looks good to me overall. Just have a few minor comments, and I think considering adding normalize
already might be a good idea.
-
I can take care of refactoring
scoring.py
then to use the newaccuracy_score
there internally, so no worries about that. -
I will also make sure the documentation builds correctly then.
Have made the changes. Although, I think you have already seen that I made a few changes to |
Thanks a lot! I am currently a bit swamped but will try to take a look at it on the weekend! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good! Here are a few minor issues I found.
Thanks for making those changes. Looks good to me now. I added the documentation, let me know if that looks good to you. |
Looks great. |
Cool thanks! I will merge then! |
Features:
with positive_label in the original scoring function). Is None by
default, in which case, average accuracy is returned
Description
This PR intends to introduce a standalone per class accuracy function
Related issues or pull requests
Fixes #617
Pull Request Checklist
./docs/sources/CHANGELOG.md
file (if applicable)./mlxtend/*/tests
directories (if applicable)mlxtend/docs/sources/
(if applicable)PYTHONPATH='.' pytest ./mlxtend -sv
and make sure that all unit tests pass (for small modifications, it might be sufficient to only run the specific test file, e.g.,PYTHONPATH='.' pytest ./mlxtend/classifier/tests/test_stacking_cv_classifier.py -sv
)flake8 ./mlxtend