<jupyter_start><jupyter_text>Retrieving trained model<jupyter_code>with open("LogReg.pickle","rb") as f:
    model = load(f)<jupyter_output><empty_output><jupyter_text>Getting column names<jupyter_code>f  = read_csv("reducedExams.csv",index_col="<NAME>:")
nomes = list(f.head().columns[:-1])
class MainWindow(tk.Frame):
    counter = 0
    def __init__(self, *args, **kwargs):
        tk.Frame.__init__(self, *args, **kwargs)
        self.button = tk.Button(self, text="Calcular novo paciente", 
                                command=self.create_window)
        self.button.pack(side="top")
        self.text = tk.Label(self,text="Diagnóstico")
        self.text.pack(side="bottom")
        self.result = []
        
    def create_window(self):
        self.counter += 1
        t = tk.Toplevel(self)
        t.wm_title("Calcular Parametros")
        inputParameters(nomes,t,self)
        
    def calculate(self):
        try:
            list(map(lambda x:float(x),self.result))
        except Exception as e:
            messagebox.showerror("Error", "Entrada inválida!")
            return None
        self.result = list(map(lambda x:0 if x=="" else float(x),self.result))
        text = model.predict(array(self.result).reshape(1,-1))[0]
        if(text):
            text = "Ceratocone"
        else:
            text= "Normal"
        self.text.config(text=text)
def getInput(campos,window,instance):
    text = []
    for campo in campos:
        text.append(campo.get())
    window.destroy()
    instance.result = text
    instance.calculate()
def inputParameters(nomes,root,instance):
    campos = []
    for campo in range(len(nomes)):
        tk.Label(root,text=nomes[campo]).grid(row=campo)
        bla = tk.Entry(root)
        bla.grid(row=campo,column=1)
        campos.append(bla)
    tk.Button(root, text = "enviar",
               command = lambda: getInput(campos,root,instance)).grid(row = campo+1)#Lambda hacking the parameters of the button to be able to pass parameters
root = tk.Tk()
main = MainWindow(root)
main.pack(side="top", fill="both", expand=True)
root.mainloop()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14232033818694223, 'fraction_numerical': 0.004227336777829967, 'mean_word_length': 2.8727272727272726, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '542948', 'license': 'MIT', 'n_tokens_mistral': 715, 'n_tokens_neox': 703, 'n_words': 125, 'path': 'User interface.ipynb', 'repo_name': 'wykthor-btracker/DM-project', 'size': '2132'}