ManjinderUNCC commited on
Commit
e75cc88
1 Parent(s): 3715140

Upload threshold.py

Browse files
Files changed (1) hide show
  1. python_Code/threshold.py +16 -0
python_Code/threshold.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import spacy
2
+
3
+ def set_threshold(model_path, threshold):
4
+ # Load the trained model
5
+ nlp = spacy.load(model_path)
6
+
7
+ # Set the threshold for text classification
8
+ nlp.get_pipe('textcat_multilabel').threshold = threshold
9
+
10
+ return nlp
11
+
12
+ # Example usage:
13
+ if __name__ == "__main__":
14
+ model_path = "./my_trained_model"
15
+ threshold = 0.21
16
+ nlp = set_threshold(model_path, threshold)