CoolFace
Apppublic

ManjinderUNCC/prodigy-ecfr-textcat

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
threshold.py17 linesDownload Raw Back to python_Code
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