AroshN's picture
Create app.py
59a92ef verified
Raw History Blame Contribute Delete
1.54 kB
import gradio as gr
import numpy as np
# If loading your actual model from HF:
# from huggingface_hub import hf_hub_download
# import joblib
# model_path = hf_hub_download(repo_id="AroshN/priority_classif_xgb", filename="model.joblib")
# model = joblib.load(model_path)
def predict_priority(task_title, days_due, estimated_hours, urgency):
# Dummy logic or model.predict():
# Replace this with your actual feature transformation & prediction
score = (urgency * 2) + (estimated_hours / (days_due + 0.1))
if score > 8:
priority = "🔴 High Priority"
elif score > 4:
priority = "🟡 Medium Priority"
else:
priority = "🟢 Low Priority"
return {
"Priority": priority,
"Urgency Level": f"{urgency}/5",
"Estimated Hours": f"{estimated_hours} hrs",
"Due In": f"{days_due} days"
}
demo = gr.Interface(
fn=predict_priority,
inputs=[
gr.Textbox(label="Task Title / Description", placeholder="Fix payment gateway timeout bug"),
gr.Slider(minimum=0, maximum=30, value=2, step=1, label="Days Until Due"),
gr.Slider(minimum=0.5, maximum=40, value=4.0, step=0.5, label="Estimated Effort (Hours)"),
gr.Radio(choices=[1, 2, 3, 4, 5], value=3, label="Urgency Rating (1=Low, 5=Critical)")
],
outputs=gr.JSON(label="Prediction Result"),
title="⚡ Task Priority Classification",
description="Interactive ML demo predicting task priority using XGBoost."
)
if __name__ == "__main__":
demo.launch()