Spaces:
Runtime error
Runtime error
Update the threshold with variance and mean
Browse files- functions/model_infer.py +5 -2
functions/model_infer.py
CHANGED
@@ -37,6 +37,9 @@ def preprocess(sentences):
|
|
37 |
def predict_from_document(sentences):
|
38 |
preprop = preprocess(sentences)
|
39 |
prediction = model.predict(preprop)
|
40 |
-
# Set the prediction threshold to 0.8
|
41 |
-
output = (
|
|
|
|
|
|
|
42 |
return output, prediction.flatten()[: len(sentences)]
|
|
|
37 |
def predict_from_document(sentences):
|
38 |
preprop = preprocess(sentences)
|
39 |
prediction = model.predict(preprop)
|
40 |
+
# Set the prediction threshold to 0.8 instead of 0.5, now use mean
|
41 |
+
output = (
|
42 |
+
prediction.flatten()[: len(sentences)]
|
43 |
+
>= np.mean(prediction) + np.var(prediction) * 2
|
44 |
+
).astype(int)
|
45 |
return output, prediction.flatten()[: len(sentences)]
|