Machine Learning, AI, NLP, Programming, Deep Dives.
per_label_accuracy(y_true, y_pred, labels): cm = confusion_matrix(y_true, y_pred, labels=labels) correct_predictions = cm.diagonal() label_totals = cm.sum(axis=1) per_label_acc = np.divide(correct_predictions, label_totals, out=np.zeros_like(correct_predictions, dtype=float), where=label_totals !=