Skip to content
Snippets Groups Projects
Commit 158da3fd authored by ivan.pavlovic's avatar ivan.pavlovic
Browse files

Modification du systeme de teste

parent 2ffce2dd
No related branches found
No related tags found
No related merge requests found
Showing
with 9483 additions and 0 deletions
# Hugging Face
## Pipeline
\ No newline at end of file
No preview for this file type
import sys
import os
# Ajouter le répertoire parent au chemin de recherche
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../")))
from model.HuggingFace.zero_shot_classification import create_classifier, classify
labels = [
"Diabetes",
"Cancer",
"Chronic respiratory disease",
"Cardiovascular diseases",
"Mental Health",
"Diabetes type 1",
"Diabetes type 2"
]
classifier = create_classifier()
sequence = "Cancer and diabetes are two of the most prevalent and impactful diseases affecting millions of people worldwide. Both conditions require extensive medical attention and lifestyle changes to manage effectively.\
Cancer is characterized by the uncontrolled growth of abnormal cells in the body. It can develop in almost any organ or tissue and is often categorized by its location, such as lung cancer, breast cancer, or skin cancer. Risk factors for cancer include genetic predisposition, smoking, exposure to harmful chemicals, and unhealthy diets. Early detection through screening and advancements in treatment, such as chemotherapy and immunotherapy, have improved outcomes for many patients.\
On the other hand, diabetes is a metabolic disorder that impairs the body’s ability to regulate blood sugar levels. Type 1 diabetes is an autoimmune condition where the body attacks insulin-producing cells, while Type 2 diabetes is often associated with lifestyle factors such as obesity and physical inactivity. Managing diabetes involves monitoring blood sugar levels, adhering to a healthy diet, regular physical activity, and, in many cases, using medications or insulin therapy.\
While these two conditions are distinct in their causes and progression, they share some common ground. For instance, both cancer and diabetes are influenced by genetic factors and lifestyle choices. Additionally, diabetes has been linked to an increased risk of developing certain types of cancer, highlighting the importance of comprehensive health monitoring.\
In the fight against these diseases, research continues to advance, offering hope for improved treatments and even potential cures. Public awareness and preventive measures, such as avoiding smoking, maintaining a healthy weight, and undergoing regular medical check-ups, play a critical role in reducing the burden of cancer and diabetes on individuals and society."
results = classify(classifier, sequence, lables=labels)
print(f"Labels: {results["labels"]}")
print(f"Scores: {results["scores"]}")
results_multi = []
for id, label in enumerate(results["labels"]):
results_multi.append({
"label": label,
"score": results["scores"][id]
})
results_solo = []
for label in labels:
tmp = []
tmp.append(label)
results = classify(classifier, sequence, lables=tmp)
print(f"Labels: {results["labels"]}")
print(f"Scores: {results["scores"]}")
results_solo.append({
"label": label,
"score": results["scores"][0]
})
for result_multi in results_multi:
for result_solo in results_solo:
if result_multi["label"] == result_solo["label"]:
print(f"\"{result_multi["label"]}\": {(result_multi["score"] + result_solo["score"]) / 2}")
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment