|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Compute F1 (harmonic mean of precision and recall) |
|
|
# Compute F1 (harmonic mean of precision and recall) |
|
|
f1 = 2 * p * r / (p + r + 1e-16) |
|
|
f1 = 2 * p * r / (p + r + 1e-16) |
|
|
|
|
|
names = [v for k, v in names.items() if k in unique_classes] # list: only classes that have data |
|
|
|
|
|
names = {i: v for i, v in enumerate(names)} # to dict |
|
|
if plot: |
|
|
if plot: |
|
|
plot_pr_curve(px, py, ap, Path(save_dir) / 'PR_curve.png', names) |
|
|
plot_pr_curve(px, py, ap, Path(save_dir) / 'PR_curve.png', names) |
|
|
plot_mc_curve(px, f1, Path(save_dir) / 'F1_curve.png', names, ylabel='F1') |
|
|
plot_mc_curve(px, f1, Path(save_dir) / 'F1_curve.png', names, ylabel='F1') |