Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -109,7 +109,7 @@ def predict_salary(job_title, experience_level, company_size, employment_type, c
|
|
| 109 |
|
| 110 |
# Check if components loaded
|
| 111 |
if model is None or scaler is None or feature_names is None or deployment_data is None:
|
| 112 |
-
return "Error: Model components could not be loaded."
|
| 113 |
|
| 114 |
# Engineer features
|
| 115 |
input_features = engineer_features_simple(job_title, experience_level, company_size, employment_type, company_location, remote_ratio)
|
|
@@ -131,16 +131,14 @@ def predict_salary(job_title, experience_level, company_size, employment_type, c
|
|
| 131 |
salary_min = int(predicted_salary - margin_of_error)
|
| 132 |
salary_max = int(predicted_salary + margin_of_error)
|
| 133 |
|
| 134 |
-
confidence_score = 0.85 # Example confidence score
|
| 135 |
-
|
| 136 |
result_range = f"Estimated Salary Range: ${salary_min:,} - ${salary_max:,}"
|
| 137 |
-
result_confidence = f"Confidence Score: {confidence_score:.0%}"
|
| 138 |
|
| 139 |
-
return result_range
|
|
|
|
| 140 |
|
| 141 |
except Exception as e:
|
| 142 |
print(f"Prediction Error: {e}")
|
| 143 |
-
return "An error occurred during prediction. Please check inputs."
|
| 144 |
|
| 145 |
# Pre-defined choices for dropdowns - Limiting to 5 core ML/AI roles + 'Other_Roles'
|
| 146 |
# These should align with the job_title_category feature engineering
|
|
@@ -227,11 +225,6 @@ with gr.Blocks(theme=gr.themes.Soft(), css=CUSTOM_CSS) as demo:
|
|
| 227 |
scale=2
|
| 228 |
)
|
| 229 |
|
| 230 |
-
explanation_output = gr.Textbox(
|
| 231 |
-
label="Prediction Confidence Score",
|
| 232 |
-
value="Confidence score will appear here after prediction",
|
| 233 |
-
)
|
| 234 |
-
|
| 235 |
gr.Markdown("## 🎯 What-If Analysis")
|
| 236 |
gr.Markdown("Try changing the parameters above to see how they affect salary predictions!")
|
| 237 |
|
|
@@ -239,7 +232,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=CUSTOM_CSS) as demo:
|
|
| 239 |
predict_btn.click(
|
| 240 |
fn=predict_salary,
|
| 241 |
inputs=[job_title, experience_level, company_size, employment_type, company_location, remote_ratio],
|
| 242 |
-
outputs=[salary_output
|
| 243 |
)
|
| 244 |
|
| 245 |
gr.Markdown("---")
|
|
@@ -251,4 +244,4 @@ with gr.Blocks(theme=gr.themes.Soft(), css=CUSTOM_CSS) as demo:
|
|
| 251 |
|
| 252 |
# Launch the app
|
| 253 |
if __name__ == "__main__":
|
| 254 |
-
demo.launch()
|
|
|
|
| 109 |
|
| 110 |
# Check if components loaded
|
| 111 |
if model is None or scaler is None or feature_names is None or deployment_data is None:
|
| 112 |
+
return "Error: Model components could not be loaded."
|
| 113 |
|
| 114 |
# Engineer features
|
| 115 |
input_features = engineer_features_simple(job_title, experience_level, company_size, employment_type, company_location, remote_ratio)
|
|
|
|
| 131 |
salary_min = int(predicted_salary - margin_of_error)
|
| 132 |
salary_max = int(predicted_salary + margin_of_error)
|
| 133 |
|
|
|
|
|
|
|
| 134 |
result_range = f"Estimated Salary Range: ${salary_min:,} - ${salary_max:,}"
|
|
|
|
| 135 |
|
| 136 |
+
return result_range
|
| 137 |
+
|
| 138 |
|
| 139 |
except Exception as e:
|
| 140 |
print(f"Prediction Error: {e}")
|
| 141 |
+
return "An error occurred during prediction. Please check inputs."
|
| 142 |
|
| 143 |
# Pre-defined choices for dropdowns - Limiting to 5 core ML/AI roles + 'Other_Roles'
|
| 144 |
# These should align with the job_title_category feature engineering
|
|
|
|
| 225 |
scale=2
|
| 226 |
)
|
| 227 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
gr.Markdown("## 🎯 What-If Analysis")
|
| 229 |
gr.Markdown("Try changing the parameters above to see how they affect salary predictions!")
|
| 230 |
|
|
|
|
| 232 |
predict_btn.click(
|
| 233 |
fn=predict_salary,
|
| 234 |
inputs=[job_title, experience_level, company_size, employment_type, company_location, remote_ratio],
|
| 235 |
+
outputs=[salary_output]
|
| 236 |
)
|
| 237 |
|
| 238 |
gr.Markdown("---")
|
|
|
|
| 244 |
|
| 245 |
# Launch the app
|
| 246 |
if __name__ == "__main__":
|
| 247 |
+
demo.launch()
|