Confusion matrix values differ from the individual class metrices found with val() method, why?

Hi,
I am working on object detection problem using yolov8 model. I trained my model on my custom dataset and evaluated my validation set by using the best weights.

I executed the below code for the first output

model = YOLO('best.pt' )
results_val = model.val()

I executed the below code for the second output where columns represent the real values and rows represent the predicted ones (which is also compatible to confusion matrix that is created in the training phase when val = True)

import pandas as pd
names = list(model.model.names.values()) + ['all']
confusion_matrix = pd.DataFrame(result_val.confusion_matrix.matrix, columns = names, index=[f'p_{item}' for item in names]).astype('int')
confusion_matrix.style.background_gradient(cmap='Blues')

in the first output the corresponding precision score for E and F groups are 0.55 and 0.821, respectively . However when I manually calculated the same metrics from the values in confusion matrix, I got 10/11 = .90 and 7/17 = .411, respectively. I checked the doc but couldn’t understand. Can someone please explain why do they differ and how can I reach the individual class metrics?

Thanks!