<jupyter_start><jupyter_text>Source Detection Benchmark<jupyter_code>import numpy as np
from karabo.Imaging.source_detection import automatic_assignment_of_ground_truth_and_prediction, calculate_evaluation_measures<jupyter_output><empty_output><jupyter_text>Evaluation Measurestrue positives (TP), false positives (FP) or false negatives (FN)true sources correctly detected (TSD) = recall = TP / (TP + FN)reliability = precision = TP / (TP + FP)The strategy used to match the detections with the sources in the reference catalogue is the following: first, the closest detection for each source in the catalogue is found. Second, associations between sources and detections that are further away than a pre-established maximum distance are deleted. We assume that the centre of two different sources cannot be closer than the FWHM of the image, so this is the maximum distance selected. Next, where detections associated with more than one source from the catalogue are found, only the closest association is kept, deleting the others. In the same way, if a true source is associated with more than one detection, only the correspondence with the shortest distance is saved. Finally, the evaluation measures are computed: TP are the detections associated with a source, FP are detections without any associated source, while FN are sources with no associations with a detection (AUTOMATIC SOURCE DETECTION IN ASTRONOMICAL IMAGES, <NAME>AS MOYSET 2014).The implementation of `automatic_assignment` is pretty similar, but not equal. For details read the docstring.<jupyter_code># with this seed and max_dist it seems to be correct
np.random.seed(42)
max_dist = .5
gtruth = np.array([[1.2,7.8],
                   [4.5,1.4],
                   [3.9,4.7],
                   [3.7,4.8]])
predicted = np.array([[3.7,4.65],
                      [1.1,8.0],
                      [3.7,4.58]])

automatic_assignment_of_ground_truth_and_prediction(gtruth, predicted, max_dist)
calculate_evaluation_measures(gtruth, predicted, max_dist)
import matplotlib.pyplot as plt

_ = plt.scatter(gtruth[:,0], gtruth[:,1], c='g')
_ = plt.scatter(predicted[:,0], predicted[:,1], c='r')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08038147138964577, 'fraction_numerical': 0.018619436875567667, 'mean_word_length': 4.54911838790932, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '304421', 'license': 'MIT', 'n_tokens_mistral': 657, 'n_tokens_neox': 611, 'n_words': 244, 'path': 'karabo/examples/source_detection_assessment.ipynb', 'repo_name': 'i4Ds/Karabo-Pipeline', 'size': '2205'}