ManjinderUNCC/prodigy-ecfr-textcat
0
1import spacy2 3def set_threshold(model_path, threshold):4 # Load the trained model5 nlp = spacy.load(model_path)6 7 # Set the threshold for text classification8 nlp.get_pipe('textcat_multilabel').threshold = threshold9 10 return nlp11 12# Example usage:13if __name__ == "__main__":14 model_path = "./my_trained_model"15 threshold = 0.2116 nlp = set_threshold(model_path, threshold)17 