Spaces:
Runtime error
Runtime error
Commit
·
7c28462
1
Parent(s):
a00beed
integrated isolation regression calibration to the bc model
Browse files- predictors.py +11 -7
predictors.py
CHANGED
|
@@ -269,19 +269,23 @@ def predict_bc_scores(input):
|
|
| 269 |
samples_len_bc = len(split_text_allow_complete_sentences_nltk(input, type_det="bc"))
|
| 270 |
segments_bc = split_text_allow_complete_sentences_nltk(input, type_det="bc")
|
| 271 |
for i in range(samples_len_bc):
|
| 272 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
bc_score = predict_bc(text_bc_model, text_bc_tokenizer, cleaned_text_bc)
|
| 274 |
bc_scores.append(bc_score)
|
| 275 |
bc_scores_array = np.array(bc_scores)
|
| 276 |
average_bc_scores = np.mean(bc_scores_array, axis=0)
|
| 277 |
bc_score_list = average_bc_scores.tolist()
|
| 278 |
-
|
| 279 |
-
# print(f"Original BC scores: AI: {bc_score_list[1]}, HUMAN: {bc_score_list[0]}")
|
| 280 |
# isotonic regression calibration
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
return bc_score
|
| 286 |
|
| 287 |
|
|
|
|
| 269 |
samples_len_bc = len(split_text_allow_complete_sentences_nltk(input, type_det="bc"))
|
| 270 |
segments_bc = split_text_allow_complete_sentences_nltk(input, type_det="bc")
|
| 271 |
for i in range(samples_len_bc):
|
| 272 |
+
|
| 273 |
+
cleaned_text_bc = (
|
| 274 |
+
segments_bc[i].replace("<s>", "").replace("</s>", "")
|
| 275 |
+
) # this is caused by above
|
| 276 |
+
|
| 277 |
+
cleaned_text_bc = remove_special_characters(cleaned_text_bc)
|
| 278 |
bc_score = predict_bc(text_bc_model, text_bc_tokenizer, cleaned_text_bc)
|
| 279 |
bc_scores.append(bc_score)
|
| 280 |
bc_scores_array = np.array(bc_scores)
|
| 281 |
average_bc_scores = np.mean(bc_scores_array, axis=0)
|
| 282 |
bc_score_list = average_bc_scores.tolist()
|
| 283 |
+
print(f"Original BC scores: AI: {bc_score_list[1]}, HUMAN: {bc_score_list[0]}")
|
|
|
|
| 284 |
# isotonic regression calibration
|
| 285 |
+
ai_score = iso_reg.predict([bc_score_list[1]])[0]
|
| 286 |
+
human_score = 1 - ai_score
|
| 287 |
+
bc_score = {"AI": ai_score, "HUMAN": human_score}
|
| 288 |
+
print(f"Calibration BC scores: AI: {ai_score}, HUMAN: {human_score}")
|
| 289 |
return bc_score
|
| 290 |
|
| 291 |
|