<jupyter_start><jupyter_text>Part III : GUI<jupyter_code>import sys
import import_ipynb
from PyQt5.QtWidgets import QWidget, QLabel, QPushButton, QLineEdit, QVBoxLayout, QHBoxLayout, QApplication, QMessageBox
from PyQt5.QtGui import QDoubleValidator, QFont
from PyQt5.QtCore import Qt, QLine
from PyQt5.QtGui import QPixmap
import FinalDiabetes
class GuiDiabetes(QWidget):

    def __init__(self) -> None :
        super(GuiDiabetes, self).__init__()
        self.sub_head = QLabel("Information de Patient")
        self.sub_head.setFont(QFont("OldEnglish",24, weight=QFont.Bold))
        self.l0 = QLineEdit()
        self.l1 = QLineEdit()
        self.l2 = QLineEdit()
        self.l3 = QLineEdit()
        self.l4 = QLineEdit()
        self.l5 = QLineEdit()
        self.l6 = QLineEdit()
        self.l7 = QLineEdit()
        self.l8 = QLineEdit()
        self.t0 = QLabel("Nom du patient:")
        self.t1 = QLabel("Age:")
        self.t2 = QLabel("Pression sanguine diastolique:")
        self.t3 = QLabel("Épaisseur de la peau:")
        self.t4 = QLabel("Insuline sérique:")
        self.t5 = QLabel("Indice de masse corporelle:")
        self.t6 = QLabel("Concentration du Glucose:")
        self.t7 = QLabel("Fonction <NAME>:")
        self.t8 = QLabel("grossesse:")
        self.r0 = QLabel("")
        self.r1 = QLabel("(années)")
        self.r2 = QLabel("(80-140mm Hg)")
        self.r3 = QLabel("(10-50mm)")
        self.r4 = QLabel("(15-276mu U/ml)")
        self.r5 = QLabel("(10-50)")
        self.r6 = QLabel("(70-180 mg/dl)")
        self.r7 = QLabel("(0.00-3.00)")
        self.r8 = QLabel("(00-17)")
        self.img = QLabel() 
        self.h0 = QHBoxLayout()
        self.h1 = QHBoxLayout()
        self.h2 = QHBoxLayout()
        self.h3 = QHBoxLayout()
        self.h4 = QHBoxLayout()
        self.h5 = QHBoxLayout()
        self.h6 = QHBoxLayout()
        self.h7 = QHBoxLayout()
        self.h8 = QHBoxLayout()
        self.clbtn = QPushButton("ANNULER")
        self.clbtn.setFixedWidth(100)
        self.submit = QPushButton("SOUMETTRE")
        self.submit.setFixedWidth(100)
        self.v1_box = QVBoxLayout()
        self.v2_box = QVBoxLayout()
        self.final_hbox = QHBoxLayout()
        self.initui()
    
    
    def initui(self) -> None:
        """ L'interface graphique est créée et les éléments des widgets sont définis ici """
        self.v1_box.addWidget(self.sub_head)
        self.v1_box.addSpacing(2)
        self.v1_box.setSpacing(2)
        #Accepter que des chifres numériques
        #self.l1.setValidator(QDoubleValidator())
        #self.l2.setValidator(QDoubleValidator())
        #self.l3.setValidator(QDoubleValidator())
        #self.l4.setValidator(QDoubleValidator())
        #self.l5.setValidator(QDoubleValidator())
        #self.l6.setValidator(QDoubleValidator())
        #self.l7.setValidator(QDoubleValidator())
        #self.l8.setValidator(QDoubleValidator())
        self.l0.setToolTip("Entrer votre nom")
        self.l0.setFixedSize(230, 30)
        self.l1.setFixedSize(230,30)
        self.l2.setFixedSize(230,30)
        self.l3.setFixedSize(230,30)
        self.l4.setFixedSize(230,30)
        self.l5.setFixedSize(230,30)
        self.l6.setFixedSize(230,30)
        self.l7.setFixedSize(230,30)
        self.l8.setFixedSize(230,30)
        self.h0.addWidget(self.t0)
        self.h0.addWidget(self.l0)
        self.h0.addWidget(self.r0)
        self.v1_box.addLayout(self.h0)
        self.h1.addWidget(self.t1)
        self.h1.addWidget(self.l1)
        self.h1.addWidget(self.r1)        
        self.v1_box.addLayout(self.h1)
        self.h2.addWidget(self.t2)
        self.h2.addWidget(self.l2)
        self.h2.addWidget(self.r2)       
        self.v1_box.addLayout(self.h2)
        self.h3.addWidget(self.t3)
        self.h3.addWidget(self.l3)
        self.h3.addWidget(self.r3)       
        self.v1_box.addLayout(self.h3)
        self.h4.addWidget(self.t4)
        self.h4.addWidget(self.l4)
        self.h4.addWidget(self.r4)      
        self.v1_box.addLayout(self.h4)
        self.h5.addWidget(self.t5)
        self.h5.addWidget(self.l5)
        self.h5.addWidget(self.r5)      
        self.v1_box.addLayout(self.h5)
        self.h6.addWidget(self.t6)
        self.h6.addWidget(self.l6)
        self.h6.addWidget(self.r6)      
        self.v1_box.addLayout(self.h6)
        self.h7.addWidget(self.t7)
        self.h7.addWidget(self.l7)
        self.h7.addWidget(self.r7)      
        self.v1_box.addLayout(self.h7)
        self.h8.addWidget(self.t8)
        self.h8.addWidget(self.l8)
        self.h8.addWidget(self.r8)      
        self.v1_box.addLayout(self.h8)
        self.h9 = QHBoxLayout()
        self.submit.clicked.connect(lambda: self.test_patient())
        self.submit.setToolTip("Cliquez pour vérifier si le patient est diabétique")
        self.clbtn.clicked.connect(lambda: self.clfn())
        self.h9.addWidget(self.submit)
        self.h9.addWidget(self.clbtn)
        pixmap = QPixmap('C:/Users/hp/Desktop/diabetes.png')
        self.img.setPixmap(pixmap)
        self.h10 = QHBoxLayout()
        self.h10.addWidget(self.img)
        self.v1_box.addLayout(self.h9)
        self.v2_box.addLayout(self.h10)
        self.report_ui()
        self.final_hbox.addLayout(self.v1_box)
        self.final_hbox.addSpacing(40)
        self.final_hbox.addLayout(self.v2_box)
        self.setLayout(self.final_hbox)


    def report_ui(self):
        self.v2_box.setSpacing(6)
        self.report_subhead = QLabel("Information sur le model.")
        self.report_subhead.setAlignment(Qt.AlignCenter)
        self.report_subhead.setFont(QFont("Times",24, weight=QFont.Bold))
        self.v2_box.addWidget(self.report_subhead)
        self.details = QLabel("Ce modèle utilise deep learning.\n")
        self.details.setFont(QFont("Arial",14, weight=QFont.Bold))
        self.details.setAlignment(Qt.AlignLeft)
        self.details.setWordWrap(True)
        self.model_details = QLabel("Remplissez vos informations et appuyez sur Soumettre pour voir le résultat.")
        self.model_details.setWordWrap(True)
        self.v2_box.addWidget(self.details)
        self.results = QLabel(" ")
        self.results.setWordWrap(True)
        self.v2_box.addWidget(self.results)
        self.v2_box.addWidget(self.model_details)
        
    def clfn(self):
        """ effacer tous les champs de texte via le bouton annuler"""
        self.l0.clear()
        self.l1.clear()
        self.l2.clear()
        self.l3.clear()
        self.l3.clear()
        self.l4.clear()
        self.l5.clear()
        self.l6.clear()
        self.l7.clear()
        self.l8.clear()
        self.report_subhead.setText("Information sur le model")
        self.model_details.setText("Remplissez vos informations et appuyez sur Soumettre pour voir le résultat.")
        self.results.setText(" ")
        self.details.setText("Ce modèle utilise deep learnin.\n")
    
    def test_patient(self) -> None:
        """ test for diabetes"""
        data = {"Age":float(self.l1.text()), "BloodPressure	":float(self.l2.text()),"SkinThickness":float(self.l3.text()), "Insulin":float(self.l4.text()), "BMI": float(self.l5.text()), "Glucose": float(self.l6.text()), "DiabetesPedigreeFunction": float(self.l7.text()), "Pregnancies": float(self.l8.text())}
        output = FinalDiabetes.predict(data)
        self.report_subhead.setText("résultat des prédictions")
        self.model_details.setText("Ce modèle utilise deep learning.\n")
        self.details.setText("Nom de patient: {}\nConcentration de glucose: {} \
\nPression sanguine diastolique: {}\nÉpaisseur du pli cutané du triceps: {}\nInsuline sérique: {}\nIndice de masse corporelle: {}".format(self.l0.text(), self.l6.text(), self.l2.text(), self.l3.text(),self.l4.text(),self.l5.text()))
        #
        if output<=0.5:
            self.results.setText("Le diagnostic suggère que le patient ne souffre pas de diabète avec un pourcentage de{}.".format(output))
        else:
            self.results.setText("Notre diagnostic suggère que le patient souffre de diabète avec un pourcentage de{}.\nVeuillez vous faire examiner rapidement.".format(output))
        self.results.setFont(QFont("Arial",14, weight=QFont.Bold))
    
    def mwindow(self) -> None:
        self.setFixedSize(1500, 900)
        self.setWindowTitle("Diabetes Predictions")
        self.show()
if __name__=="__main__":
    app = QApplication(sys.argv)
    a_window = GuiDiabetes()
    a_window.mwindow()
    sys.exit(app.exec_())<jupyter_output>[0.48101503]
[0.67712057]
{'fraction_non_alphanumeric': 0.13474101726551563, 'fraction_numerical': 0.035230984601026596, 'mean_word_length': 2.545492142266336, 'pattern_counts': {'":': 9, '<': 6, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '335777', 'license': 'Apache-1.1', 'n_tokens_mistral': 3203, 'n_tokens_neox': 3077, 'n_words': 451, 'path': 'GUI Diabetes_Predictions.ipynb', 'repo_name': 'mohamedhafidi33/Diabetes_predictions', 'size': '8582'}