Calculate the accuracy score of predictions compared to true labels. Given two arrays (true labels and predicted labels), return the fraction of correct predictions.
import numpy as np
def accuracy_score(y_true, y_pred):
y_true = np.array(y_true)
y_pred = np.array(y_pred)
correct = np.sum(y_true == y_pred)
return correct / len(y_true)True values (correct predictions).