<jupyter_start><jupyter_text><jupyter_code>import pickle
 
modelo = open('modelo_consumo_cerveja','rb')
lm_new = pickle.load(modelo)
modelo.close()
 
temp_max = 30.5
chuva = 12.2
fds = 0
entrada = [[temp_max, chuva, fds]]
print('{0:.2f} litros'.format(lm_new.predict(entrada)[0]))<jupyter_output>26094.90 litros<jupyter_text>Visualização<jupyter_code># Importando bibliotecas
from ipywidgets import widgets, HBox, VBox
from IPython.display import display

# Criando os controles do formulário
temp_max = widgets.Text(description="Temperatura")
chuva = widgets.Text(description="Chuva")
fds = widgets.RadioButtons(options=['Não', 'Sim'], description="FDS")
botao = widgets.Button(description="Simular")

# Posicionando os controles
left = VBox([temp_max, chuva])
right = VBox([fds])
inputs = HBox([left, right])

def simulador(sender):
    entrada=[[
                float(temp_max.value if temp_max.value else 0), 
                float(chuva.value if chuva.value else 0), 
                float(1 if (fds.value=='Sim') else 0)
             ]]
    print('{0:.2f} litros'.format(lm_new.predict(entrada)[0]))

botao.on_click(simulador)  
# Mostrando o formulário
display(inputs, botao)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14014839241549876, 'fraction_numerical': 0.01978565539983512, 'mean_word_length': 4.950980392156863, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '408350', 'license': 'Apache-2.0', 'n_tokens_mistral': 482, 'n_tokens_neox': 454, 'n_words': 84, 'path': 'linear regression/04_test_read_modelo_reg.ipynb', 'repo_name': 'BrunoASNascimento/ml_study', 'size': '1213'}