Welcome to our Support Center



Computes the precision of the predictions with respect to the labels. Type : polymorphic.



Input parameters


Β y_pred : array, predicted values (logits values).
Β y_true : array, true values (logits values, or binary values if the threshold value is between 0 and 1).
thresholds : float, representing the threshold for deciding whether prediction and true values are 1 or 0 (above the threshold is true, below is false).


Output parameters


precision : float, result.

Use cases

Accuracy is a widely used metric in binary and multiclass classification tasks in machine learning. Accuracy is the ratio between the number of true positives (examples correctly identified as belonging to a specific class) and the sum of true positives and false positives (examples incorrectly identified as belonging to that class).

Precision is therefore a measure of a model’s ability to avoid labeling a negative sample as positive. It is used when the costs of false positives are high. For example :

    • Information retrieval : when searching for relevant documents or information on the web, we want to minimize the number of irrelevant results (false positives).
    • Medical diagnosis : in disease detection, it’s important to minimize false positives, as a false positive diagnosis could lead to unnecessary or inappropriate treatment.
    • Spam detection : when classifying e-mails as “spam” or “non-spam”, we want to minimize the number of false positives, as a legitimate e-mail classified as spam (a false positive) could result in the loss of important messages.
    • Fraud detection systems : in banking and finance, it is crucial to minimize the number of legitimate transactions wrongly identified as fraudulent (false positives), as this could lead to customer inconvenience.



Precision is a measure commonly used to evaluate classification models. It is calculated as the number of true positives (TP) divided by the sum of true positives and false positives (FP), i.e. TP / (TP + FP). True positives are cases where the model correctly predicts the positive class, while false positives are cases where the model incorrectly predicts the positive class. High precision means that the model accurately predicts the positive class, but does not take into account its effectiveness in correctly predicting the negative class.



All these exemples are snippets PNG, you can drop these Snippet onto the block diagram and get the depicted code added to your VI (Do not forget to install HAIBAL library to run it).

Easy to use

Table of Contents