Precision Score in Python

Simon Leung
Simon Leung used Ask the Experts™
on
Any idea how the follow result is calculated :

Testlabels3           = ['Red', 'Green', 'Green', 'Red', 'Yellow']
PredictedLabels3 = ['Red', 'Red', 'Green', 'Yellow', 'Yellow']

precision_score(TestLabels3, PredictedLabels3, average=None)
result : array([1. , 0.5, 0.5])

precision_score(TestLabels3, PredictedLabels3, average='weighted')
result : 0.7
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I will not be able to answer this question. Others might.
The chance to get an answer might be higher if you mention from which library precision_score is coming from.

Perhaps you add the statement that imports precision_score to your question and you add the module containing precision score to your question's title?
Software Engineer
Distinguished Expert 2018
Commented:
Documentation: https://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_score.html
and: https://scikit-learn.org/stable/user_guide.html
I guess it has to do with machine learning:  https://en.wikipedia.org/wiki/Precision_and_recall

An i have not delved machine learning  on that level. (quite not my line of work (yet?)).
So the Wikipedia article might be a start on finding more info.

Additional:
Laymans terms of Wikipedia article: (ultra short summary)
https://www.quora.com/What-is-the-best-way-to-understand-the-terms-precision-and-recall
This refers to python open source projects that are using this function:
https://www.programcreek.com/python/example/89265/sklearn.metrics.precision_score

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial