Zeyadd-Mostaffa commited on
Commit
071143b
·
verified ·
1 Parent(s): ef2280b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -27,7 +27,7 @@ model = load_model()
27
 
28
  # Prediction function with consistent feature names
29
  def predict_employee_status(satisfaction_level, last_evaluation, number_project,
30
- average_monthly_hours, time_spent_company,
31
  work_accident, promotion_last_5years, salary, department, threshold=0.5):
32
 
33
  # One-hot encode the department
@@ -39,22 +39,22 @@ def predict_employee_status(satisfaction_level, last_evaluation, number_project,
39
  if department in departments:
40
  department_features[f"department_{department}"] = 1
41
 
42
- # Generate Interaction Features
43
  satisfaction_evaluation = satisfaction_level * last_evaluation
44
  work_balance = average_monthly_hours / number_project
45
 
46
- # Prepare the input with all expected features
47
  input_data = {
48
  "satisfaction_level": [satisfaction_level],
49
  "last_evaluation": [last_evaluation],
50
  "number_project": [number_project],
51
  "average_monthly_hours": [average_monthly_hours],
52
- "time_spent_company": [time_spent_company], # Corrected
53
  "Work_accident": [work_accident],
54
  "promotion_last_5years": [promotion_last_5years],
55
  "salary": [salary],
56
- "satisfaction_evaluation": [satisfaction_evaluation], # Added
57
- "work_balance": [work_balance], # Added
58
  **department_features
59
  }
60
 
@@ -84,7 +84,7 @@ def gradio_interface():
84
  gr.Number(label="Last Evaluation (0.0 - 1.0)"),
85
  gr.Number(label="Number of Projects (1 - 10)"),
86
  gr.Number(label="Average Monthly Hours (80 - 320)"),
87
- gr.Number(label="Time Spent at Company (Years)"), # Corrected
88
  gr.Radio([0, 1], label="Work Accident (0 = No, 1 = Yes)"),
89
  gr.Radio([0, 1], label="Promotion in Last 5 Years (0 = No, 1 = Yes)"),
90
  gr.Radio([0, 1, 2], label="Salary (0 = Low, 1 = Medium, 2 = High)"),
 
27
 
28
  # Prediction function with consistent feature names
29
  def predict_employee_status(satisfaction_level, last_evaluation, number_project,
30
+ average_monthly_hours, time_spend_company,
31
  work_accident, promotion_last_5years, salary, department, threshold=0.5):
32
 
33
  # One-hot encode the department
 
39
  if department in departments:
40
  department_features[f"department_{department}"] = 1
41
 
42
+ # Automatically Generate Interaction Features
43
  satisfaction_evaluation = satisfaction_level * last_evaluation
44
  work_balance = average_monthly_hours / number_project
45
 
46
+ # Prepare the input with all expected features as a DataFrame with column names
47
  input_data = {
48
  "satisfaction_level": [satisfaction_level],
49
  "last_evaluation": [last_evaluation],
50
  "number_project": [number_project],
51
  "average_monthly_hours": [average_monthly_hours],
52
+ "time_spend_company": [time_spend_company], # Corrected to match training data
53
  "Work_accident": [work_accident],
54
  "promotion_last_5years": [promotion_last_5years],
55
  "salary": [salary],
56
+ "satisfaction_evaluation": [satisfaction_evaluation], # Added for model compatibility
57
+ "work_balance": [work_balance], # Added for model compatibility
58
  **department_features
59
  }
60
 
 
84
  gr.Number(label="Last Evaluation (0.0 - 1.0)"),
85
  gr.Number(label="Number of Projects (1 - 10)"),
86
  gr.Number(label="Average Monthly Hours (80 - 320)"),
87
+ gr.Number(label="Time Spend at Company (Years)"), # Corrected to match the notebook
88
  gr.Radio([0, 1], label="Work Accident (0 = No, 1 = Yes)"),
89
  gr.Radio([0, 1], label="Promotion in Last 5 Years (0 = No, 1 = Yes)"),
90
  gr.Radio([0, 1, 2], label="Salary (0 = Low, 1 = Medium, 2 = High)"),