Skip to content
Snippets Groups Projects
Commit e5e43b0d authored by Ivan Pavlovich's avatar Ivan Pavlovich
Browse files

Teste de model locale de Ollama et ajout du F1 Score dans les résultats du teste

parent 497926b0
No related branches found
No related tags found
No related merge requests found
......@@ -37,4 +37,13 @@ def get_precision(confusion_matrix):
denominator = (confusion_matrix[0][0] + confusion_matrix[0][1])
if denominator == 0:
return 0
return confusion_matrix[0][0] / denominator
\ No newline at end of file
return confusion_matrix[0][0] / denominator
def get_f1_score(confusion_matrix):
precision = get_precision(confusion_matrix)
recall = get_tpr(confusion_matrix)
denominator = (precision + recall)
if denominator == 0:
return 0
return 2 * ((precision * recall) / denominator)
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -161,6 +161,7 @@ for length_category in LENGTH_CATEGORIES:
print(f"True Positive Rate (TPR): {data['results'][length_category]['TPR']}")
print(f"True Negative Rate (TNR): {data['results'][length_category]['TNR']}")
print(f"Precision: {data['results'][length_category]['Precision']}")
print(f"F1 Score: {data['results'][length_category]['F1']}")
print("---------------------------------")
print(f"Name: ALL")
......@@ -169,4 +170,5 @@ print(f"Result confusion matrix: {data['results']['ALL']['confusion matrix']}")
print(f"True Positive Rate (TPR): {data['results']['ALL']['TPR']}")
print(f"True Negative Rate (TNR): {data['results']['ALL']['TNR']}")
print(f"Precision: {data['results']['ALL']['Precision']}")
print(f"F1 Score: {data['results']['ALL']['F1']}")
print()
\ No newline at end of file
......@@ -4,7 +4,7 @@ import json
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../")))
from testModel.metrics import get_tpr, get_tnr, get_precision
from testModel.metrics import get_tpr, get_tnr, get_precision, get_f1_score
from variables.articles import LENGTH_CATEGORIES
def get_dataset_filename(name):
......@@ -96,7 +96,8 @@ def create_results():
'confusion matrix': [[0, 0], [0, 0]],
'TPR': 0,
'TNR': 0,
'Precision': 0
'Precision': 0,
'F1': 0
}
def store_results(confusion_matrix):
......@@ -104,5 +105,6 @@ def store_results(confusion_matrix):
"confusion matrix": confusion_matrix,
"TPR": get_tpr(confusion_matrix),
"TNR": get_tnr(confusion_matrix),
"Precision": get_precision(confusion_matrix)
"Precision": get_precision(confusion_matrix),
"F1": get_f1_score(confusion_matrix)
}
\ No newline at end of file
......@@ -13,5 +13,7 @@ MODELS = {
'MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli': {'predict': classify, 'isHuggingFace': True, 'pipline': create_classifier},
'MoritzLaurer/deberta-v3-base-zeroshot-v1.1-all-33': {'predict': classify, 'isHuggingFace': True, 'pipline': create_classifier},
'MoritzLaurer/multilingual-MiniLMv2-L6-mnli-xnli': {'predict': classify, 'isHuggingFace': True, 'pipline': create_classifier},
'llama3.2': {'predict': ollama.classify, 'isHuggingFace': False, 'pipline': None}
'llama3.2': {'predict': ollama.classify, 'isHuggingFace': False, 'pipline': None},
'mistral-small': {'predict': ollama.classify, 'isHuggingFace': False, 'pipline': None},
'deepseek-v2': {'predict': ollama.classify, 'isHuggingFace': False, 'pipline': None}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment