Spaces:
Runtime error
Runtime error
| import pickle | |
| import gradio as gr | |
| # Load the pickled model | |
| with open('./salifort_rf3.pickle', 'rb') as file: | |
| model = pickle.load(file) | |
| # Define the function for making predictions | |
| def salifort(last_evaluation, number_project, tenure, work_accident, promotion_last_5years, salary, department_IT, department_RandD, department_accounting, department_hr, department_management, department_marketing, department_product_mng, department_sales, department_support, department_technical, overworked): | |
| inputs = [[float(last_evaluation), float(number_project), float(tenure), float(work_accident), float(promotion_last_5years), float(salary), float(department_IT), float(department_RandD), float(department_accounting), float(department_hr), float(department_management), float(department_marketing), float(department_product_mng), float(department_sales), float(department_support), float(department_technical), float(overworked)]] | |
| prediction = model.predict(inputs) | |
| prediction_value = prediction[0] | |
| if prediction_value == 0: | |
| label_text = 'Employee would not leave the company 🟢' | |
| else: | |
| label_text = 'Employee will leave the company 🔴' | |
| return label_text | |
| # Create the Gradio interface | |
| salifort_ga = gr.Interface(fn=salifort, | |
| inputs = [ | |
| gr.Number(0, 1, label="last_evaluation: [0 1]"), | |
| gr.Number(2, 7, label="number_project: [2 to 7]"), | |
| gr.Number(2, 10, label="tenure: [2 to 10]"), | |
| gr.Number(0, 1, label="work_accident: [0 1]"), | |
| gr.Number(0, 1, label="promotion_last_5years: [0 1]"), | |
| gr.Number(0, 2, label="salary: [0 1 2]"), | |
| gr.Number(0, 1, label="department_IT: [0 1]"), | |
| gr.Number(0, 1, label="department_RandD: [0 1]"), | |
| gr.Number(0, 1, label="department_accounting: [0 1]"), | |
| gr.Number(0, 1, label="department_hr: [0 1]"), | |
| gr.Number(0, 1, label="department_management: [0 1]"), | |
| gr.Number(0, 1, label="department_marketing: [0 1]"), | |
| gr.Number(0, 1, label="department_product_mng: [0 1]"), | |
| gr.Number(0, 1, label="department_sales: [0 1]"), | |
| gr.Number(0, 1, label="department_support: [0 1]"), | |
| gr.Number(0, 1, label="department_technical: [0 1]"), | |
| gr.Number(0, 1, label="overworked: [0 1]") | |
| ], | |
| outputs = "text", title="Data-driven suggestions for HR - Salifort Motors - Employee Retention", | |
| examples = [ | |
| [0, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], | |
| [0, 3, 3, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1], | |
| [0, 2, 3, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], | |
| [0, 6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1] | |
| ], | |
| description="Employee Retention Prediction Using Machine Learning", | |
| theme='dark' | |
| ) | |
| salifort_ga.launch(share=True) |