INNER CODE UNIT · Python
simple_accuracy
hooshvare/parsbert · scripts/utils.py:144
def simple_accuracy(predictions, labels):
return (predictions == labels).mean()
def acc_and_f1(predictions, labels):
acc = simple_accuracy(predictions, labels)
f1 = f1_score(y_true=labels, y_pred=predictions, average='weighted')
return {
"acc": acc,
"f1": f1,
"acc_and_f1": (acc + f1) / 2,
}
def mse_and_mae_and_r2(predictions, labels):
return {
"mse": mean_squared_error(labels, predictions),
"mae": mean_absolute_error(labels, predictions),