# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="view-in-github" colab_type="text"
# <a href="https://colab.research.google.com/github/BrunoASNascimento/ml_study/blob/master/04_test_read_modelo_reg.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>

# + id="W9zBotG72URh" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 34} outputId="dadd082a-c394-4a7a-c91d-2c68d33aeac7"
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]))

# + [markdown] id="ZlgS54pd5yQs" colab_type="text"
# #Visualização
#

# + id="-E86HADh50z_" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 164, "referenced_widgets": ["608c0200efa345bc90b436499edb464c", "9e7af7ec53704b82b0518f718b874581", "83c7e8d20e9a4d22977f565364b867b8", "<KEY>", "<KEY>", "<KEY>", "<KEY>", "<KEY>", "8fde81f2eedd4f8d8a2d86837d044f03", "7357b94c7cec49bf8a20b3e270106aea", "<KEY>", "3d5d854fb8ad4a3db0fd89a23c12ee73", "<KEY>", "668fa1d543344857a9365e035cae859d", "cff12f461193457997ef66a742adeba2", "94c545c1c47f43ebab0a2184a9ace4ab", "45e8b4f56ee44f76960a07d228f7c546", "d90b215d56c545adb5431cc6e82567df"]} outputId="3a53a104-3d62-431b-c3d2-cae7e5cd27dc"
# 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)

StarcoderdataJupyterScriptsDedupFiltered