Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import pandas as pd | |
| import joblib | |
| from huggingface_hub import hf_hub_download | |
| # Load model from Hugging Face Model Hub | |
| model_path = hf_hub_download( | |
| repo_id="AngadSi/wellness-purchase-prediction-model", | |
| filename="wellness_purchase_model.joblib", | |
| repo_type="model" | |
| ) | |
| model = joblib.load(model_path) | |
| def predict_purchase( | |
| Age, | |
| MonthlyIncome, | |
| NumberOfTrips, | |
| PitchSatisfactionScore | |
| ): | |
| df = pd.DataFrame([{ | |
| "Age": Age, | |
| "MonthlyIncome": MonthlyIncome, | |
| "NumberOfTrips": NumberOfTrips, | |
| "PitchSatisfactionScore": PitchSatisfactionScore | |
| }]) | |
| pred = model.predict(df)[0] | |
| prob = model.predict_proba(df)[0][1] | |
| return { | |
| "Prediction": int(pred), | |
| "Purchase_Probability": round(prob, 3) | |
| } | |
| demo = gr.Interface( | |
| fn=predict_purchase, | |
| inputs=[ | |
| gr.Number(label="Age"), | |
| gr.Number(label="Monthly Income"), | |
| gr.Number(label="Number of Trips"), | |
| gr.Number(label="Pitch Satisfaction Score") | |
| ], | |
| outputs="json", | |
| title="Wellness Tourism Purchase Prediction", | |
| description="Predicts whether a customer will purchase the Wellness Tourism Package." | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch(server_name="0.0.0.0", server_port=7860) | |