How can accuracy be greater than my precision, recall and F-Score metrics? I have trained two models to detect gestures using ambient light and solar panels. I am now testing the two models in different light scenarios. I have a Convolutional Neural Network model that performs slightly better than a Random Forest in terms of accuracy, but in darker intensities (<650 lux), RF outperforms CNN in terms of precision and recall.
My question is - How can my CNN model have a greater accuracy than precision, recall and F-score? Such as my living room dataset (350 lux).
And, how can my RF model after 650 lux outperform CNN in precision, recall and F-score but still receive a lower accuracy score than my CNN.
Could someone please help explain this to me,
Thank you in advance
from sklearn.metrics import precision_score, recall_score, f1_score, accuracy_score
from sklearn.metrics import confusion_matrix

array_predicted = torch.tensor([])
array_labels =  torch.tensor([])

loss_fn = nn.CrossEntropyLoss()


val_loss = 0
precision, recall, f1, accuracy = [], [], [], []
model.eval()
with torch.no_grad():
    for i,(data, label) in enumerate(test_loader):
        outputs = model(data.to(device))
        val_loss += loss_fn(outputs, label.to(device))

        predicted_classes = torch.max(outputs, 1)[1] # get class from network's prediction

        array_predicted = torch.cat((array_predicted.cpu(),predicted_classes.cpu()),0) 
        array_labels = torch.cat((array_labels.cpu(), label.cpu()),0)

        # calculate P/R/F1/A metrics for batch
        for acc, metric in zip((precision, recall, f1), 
                                (precision_score, recall_score, f1_score)):
            acc.append(
                metric(label.cpu(), predicted_classes.cpu(), average="macro")
            )
        accuracy.append(accuracy_score(label.cpu(), predicted_classes.cpu()))

[sum(x*100)//len(x) for x in [precision, recall, f1, accuracy]]





I would like to comment with a question first, but I can't so I will try to write an answer.
Is your dataset balanced?
This question is very important. Accuracy is very sensitive to dataset imbalance. In such cases, balanced accuracy is more appropriate and will give you a better value.

Consider a sample with 95 negative and 5 positive values. Classifying all values as negative in this case gives 0.95 accuracy score [...] For the previous example (95 negative and 5 positive samples), classifying all as negative gives 0.5 balanced accuracy score (the maximum bACC score is one), which is equivalent to the expected value of a random guess in a balanced data set. Wikipedia

