File size: 1,544 Bytes
59a92ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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()