Skip to content

Instantly share code, notes, and snippets.

@gabguerin
Last active December 13, 2021 10:25
Show Gist options
  • Save gabguerin/2259948424837c742722ab5931249668 to your computer and use it in GitHub Desktop.
Save gabguerin/2259948424837c742722ab5931249668 to your computer and use it in GitHub Desktop.
def _get_sign_predicted(self, batch_size=5, threshold=0.5):
# Get the list (of size batch_size) of the most similar reference signs
sign_names = self.sign_dictionary.iloc[:batch_size]["name"].values
# Count the occurrences of each sign and sort them by ascending order
sign_counter = Counter(sign_names).most_common()
# Check if the most similar sign's proportion in the batch is greater than the threshold
predicted_sign, count = sign_counter[0]
if count / batch_size < threshold:
return "Signe inconnu"
return predicted_sign
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment