.. toctree:: :maxdepth: 3 :caption: Precision Score (PS)
.. toctree:: :maxdepth: 3
.. toctree:: :maxdepth: 3
.. toctree:: :maxdepth: 3
The precision is the ratio tp / (tp + fp) where tp is the number of true positives and fp the number of false positives. The precision is intuitively the ability of the classifier not to label as positive a sample that is negative.
In the multi-class and multi-label case, this is the average of the PS score of each class with weighting depending on the average parameter.
- Best possible score is 1.0, higher value is better. Range = [0, 1]
- https://towardsdatascience.com/multi-class-metrics-made-simple-part-i-precision-and-recall-9250280bddc2
- https://www.debadityachakravorty.com/ai-ml/cmatrix/
- https://neptune.ai/blog/evaluation-metrics-binary-classification
- https://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_score.html#sklearn.metrics.precision_score
Example:
from numpy import array
from permetrics.classification import ClassificationMetric
## For integer labels or categorical labels
y_true = [0, 1, 0, 0, 1, 0]
y_pred = [0, 1, 0, 0, 0, 1]
# y_true = ["cat", "ant", "cat", "cat", "ant", "bird", "bird", "bird"]
# y_pred = ["ant", "ant", "cat", "cat", "ant", "cat", "bird", "ant"]
cm = ClassificationMetric(y_true, y_pred)
print(cm.PS(average=None))
print(cm.PS(average="micro"))
print(cm.PS(average="macro"))
print(cm.PS(average="weighted"))