<jupyter_start><jupyter_text>Grid search<jupyter_code>steps = np.arange(0.05, 1, 0.05)

fmes_grid = np.zeros((len(steps)))

for i, t in enumerate(steps):
    results = [prior_util.decode(p, t) for p in preds]
    fmes = evaluate_results(data, results, gt_util, iou_thresh=0.5, max_dets=100, return_fmeasure=True)
    fmes_grid[i] = fmes
    print('threshold %.2f f-measure %.2f' % (t, fmes))
max_idx = np.argmax(fmes_grid)
print(steps[max_idx], fmes_grid[max_idx])
plt.figure(figsize=[12,6])
plt.plot(steps, fmes_grid)
plt.plot(steps[max_idx], fmes_grid[max_idx], 'or')
plt.xticks(steps)
plt.grid()
plt.xlabel('threshold')
plt.ylabel('f-measure')
plt.show()
confidence_threshold = 0.30 # voc model on voc 2007 test
#confidence_threshold = 0.70 # voc model on voc 2012 test
#confidence_threshold = 0.28 # voc model on coco test
#confidence_threshold = 0.25 # coco model on coco test<jupyter_output><empty_output><jupyter_text>Precision-recall curve, mean Average Precision<jupyter_code>results = [prior_util.decode(p, confidence_threshold=0.01, keep_top_k=400) for p in tqdm(preds)]
evaluate_results(data, results, gt_util, iou_thresh=0.5, max_dets=100)<jupyter_output>100%|██████████| 4952/4952 [00:12<00:00, 384.95it/s]<jupyter_text>Confusion matrix of local predictions<jupyter_code>results = [prior_util.decode(p, confidence_threshold) for p in tqdm(preds)]
encoded_gt = [prior_util.encode(d) for d in tqdm(data)]

y_true_all = []
y_pred_all = []

for i in range(len(data)):
    y_true = np.argmax(encoded_gt[i][:,4:], axis=1)
    y_pred = np.argmax(preds[i][:,4:], axis=1)
    #prior_object_idx = np.where(y_true)[0] # gt prior box contains object
    prior_object_idx = np.where(y_true+y_pred)[0] # gt or prediction prior box contains object
    y_true_all.extend(y_true[prior_object_idx])
    y_pred_all.extend(y_pred[prior_object_idx])

cm = confusion_matrix(y_true_all, y_pred_all, gt_util.num_classes)
plot_confusion_matrix(cm, gt_util.classes, figsize=[12]*2)
accuracy(y_true_all, y_pred_all)<jupyter_output>100%|██████████| 4952/4952 [00:04<00:00, 1007.23it/s]
100%|██████████| 4952/4952 [00:36<00:00, 136.39it/s]
{'fraction_non_alphanumeric': 0.15677966101694915, 'fraction_numerical': 0.06120527306967985, 'mean_word_length': 6.589285714285714, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '135932', 'license': 'MIT', 'n_tokens_mistral': 986, 'n_tokens_neox': 872, 'n_words': 160, 'path': 'SSD_evaluation.ipynb', 'repo_name': 'sloppyjuicy/ssd_detectors', 'size': '2124'}