File size: 1,769 Bytes
e64ff87
 
 
 
 
 
 
04dc613
 
 
 
 
 
6a76f12
04dc613
 
a73e587
3052fbf
 
 
04dc613
3052fbf
3e5cc51
3052fbf
 
3e5cc51
04dc613
3e5cc51
04dc613
 
e64ff87
04dc613
 
6a76f12
04dc613
e64ff87
 
3052fbf
e64ff87
 
 
cd6a473
e64ff87
cd6a473
e64ff87
cd6a473
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# import pandas as pd
# import streamlit as st
# from transformers import pipeline
# from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, balanced_accuracy_score

# # Charger le modèle pré-entraîné
# classifier_model = "morit/french_xlm_xnli"
import pandas as pd
import streamlit as st
from transformers import pipeline
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, balanced_accuracy_score

# Charger le modèle pré-entraîné
classifier_model = "MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli"
classifier = pipeline("zero-shot-classification", model=classifier_model)
# Afficher l'entête
st.header("Sentiment Analysis")
df = pd.read_csv("fic.csv", sep=";")
# Récupérer les commentaires en liste
comments = df["text"].tolist()

# Afficher l'entête
st.header("Text Analysis")

# Créer une selectbox pour choisir un commentaire
selected_comment = st.selectbox("Choose comments or type text", comments)
# Afficher le commentaire sélectionné dans l'input text
text = st.text_area('Text zone', value=selected_comment)

# Labels candidats pour la classification
candidate_labels = [1, 0]

# Modèle de phrase pour la formation de l'hypothèse
hypothesis_template = "This example is a  {}."

# Ajouter un bouton pour déclencher l'analyse
if st.button("Analyser le texte"):
    if text and candidate_labels:
        result = classifier(text, candidate_labels, hypothesis_template=hypothesis_template)
        
        if result['labels'][0] == 1:
            st.info(f"Résults Good comments ,accuracy {result['scores'][0]*100:.2f}%")
        if result['labels'][0] == 0:
            st.info(f" Bad comments,accuracy= {result['scores'][0]*100:.2f}%")
    else:
        st.write("Text Analysis.")