Spaces:
Build error
Build error
Download python_Code/threshold.py from ManjinderUNCC/prodigy-ecfr-textcat: direct link, hf CLI and curl.
- Browser
- Download file 395 Bytes
-
https://huggingface.co/spaces/ManjinderUNCC/prodigy-ecfr-textcat/resolve/main/python_Code/threshold.py
- Command line
-
hf download hf://spaces/ManjinderUNCC/prodigy-ecfr-textcat/python_Code/threshold.py
-
curl -L -o threshold.py https://huggingface.co/spaces/ManjinderUNCC/prodigy-ecfr-textcat/resolve/main/python_Code/threshold.py
395 Bytes
| import spacy | |
| def set_threshold(model_path, threshold): | |
| # Load the trained model | |
| nlp = spacy.load(model_path) | |
| # Set the threshold for text classification | |
| nlp.get_pipe('textcat_multilabel').threshold = threshold | |
| return nlp | |
| # Example usage: | |
| if __name__ == "__main__": | |
| model_path = "./my_trained_model" | |
| threshold = 0.21 | |
| nlp = set_threshold(model_path, threshold) | |