File size: 3,469 Bytes
15604af 31a5b4b 15604af 31a5b4b 15604af |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
'''
cd h2o-3.42.0.2
java -jar h2o.jar
http://localhost:54321
source h20env/bin/activate
jupyter notebook
'''
import h2o
import pandas as pd
import matplotlib as plt
import gradio as gr
import random
plt.use("Agg")
h2o.init()
gbm_saved_model = h2o.load_model('/mnt/c/Users/MI/Documents/Machine learning/retention_automl/GBM_2_AutoML_1_20230812_124802')
def predict(*args):
df = pd.DataFrame([list(args)], columns=['department','promoted','review','projects','salary','tenure','satisfaction','bonus','avg_hrs_month'])
x = h2o.H2OFrame(df)
pos_pred = gbm_saved_model.predict(x)
#str(pos_pred)
return (pos_pred.as_data_frame())
unique_department = ['IT',
'admin',
'engineering',
'finance',
'logistics',
'marketing',
'operations',
'retail',
'sales',
'support']
unique_salary = ['high', 'low', 'medium']
with gr.Blocks() as demo:
gr.Markdown("""
**Employee leave probability prediction using H2O AutoML demo app**.
Data set used - https://www.kaggle.com/datasets/marikastewart/employee-turnover .
Jupyter Notebook is available at *Files* tab
""")
with gr.Row():
with gr.Column():
department = gr.Dropdown(
label="Department",
choices=unique_department,
value=lambda: random.choice(unique_department),
)
promoted = gr.Number(
label="Promoted",
minimum=0.0,
maximum=1.0
)
review = gr.Slider(label="Review", minimum=0, maximum=1, step=0.01, randomize=True)
# review = gr.Number(
# label="Review",
# minimum=0.0,
# maximum=1.0
# )
projects = gr.Number(
label="Projects",
minimum=0.0,
maximum=30.0
)
salary = gr.Dropdown(
label="salary",
choices=unique_salary,
value=lambda: random.choice(unique_salary),
)
tenure = gr.Number(
label="Tenure",
minimum=0.0,
maximum=50.0
)
satisfaction = gr.Slider(label="Satisfaction", minimum=0, maximum=1, step=0.01, randomize=True)
# satisfaction = gr.Number(
# label="Satisfaction",
# minimum=0.0,
# maximum=1.0
# )
bonus = gr.Number(
label="Bonus",
minimum=0.0,
maximum=1.0
)
avg_hrs_month = gr.Number(
label="Avg_hrs_month",
minimum=0.0,
maximum=500.0
)
with gr.Column():
label = gr.Dataframe()
with gr.Row():
predict_btn = gr.Button(value="Predict")
predict_btn.click(
predict,
inputs=[
department,
promoted,
review,
projects,
salary,
tenure,
satisfaction,
bonus,
avg_hrs_month
],
outputs=[label],
)
demo.launch() |