BhalML's picture
Update app.py
a6c4221
raw
history blame
1.71 kB
import numpy as np
import pandas as pd
import gradio as gr
import joblib
import pickle
from sklearn.tree import DecisionTreeClassifier
with open('./model_playgolf_decision_tree_classifier','rb') as f:
dct_playgolf = pickle.load(f)
def predict(Windy: bool = True
,Outlook_Rainy: bool = True
,Outlook_Sunny: bool = True
,Temp_Hot: bool = True
,Temp_Mild: bool = True
,Humidity_Normal: bool = True):
prediction_array = np.array([Windy, Outlook_Rainy, Outlook_Sunny, Temp_Hot, Temp_Mild, Humidity_Normal], dtype=np.double)
play_golf = dct_playgolf.predict([prediction_array])
if play_golf == ['Yes']:
return f'Weather is good for playing golf'
else:
return f'Weather is horrible for playing golf'
with gr.Blocks() as playgolf:
with gr.Row() as outlookrow:
Windy = gr.Dropdown(choices=[True,False], label="Windy Day?")
Outlook_Rainy= gr.Dropdown(choices=[True,False], label="Rainy Day?")
Outlook_Sunny= gr.Dropdown(choices=[True,False], label="Sunny Day?")
with gr.Row() as Temprow:
Temp_Hot = gr.Dropdown(choices=[True,False], label="Select Is Hot Today?")
Temp_Mild= gr.Dropdown(choices=[True,False], label="Is Mild Temperature Today?")
Humidity_Normal= gr.Dropdown(choices=[True,False], label="Is Humidity Normal?")
submit = gr.Button(value='Predict')
output = gr.Textbox(label='Is weather good to play Golf?', interactive = False)
submit.click(predict, inputs=[Windy,Outlook_Rainy,Outlook_Sunny,Temp_Hot,Temp_Mild,Humidity_Normal], outputs = [output])
playgolf.launch(share = False, debug = True)