Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import joblib
|
| 4 |
+
from huggingface_hub import hf_hub_download
|
| 5 |
+
|
| 6 |
+
st.set_page_config(page_title="Wellness Tourism Prediction", layout="centered")
|
| 7 |
+
|
| 8 |
+
st.title("Wellness Tourism Purchase Prediction")
|
| 9 |
+
st.write("Predict whether a customer will purchase the Wellness Tourism Package.")
|
| 10 |
+
|
| 11 |
+
# Load model from Hugging Face Model Hub
|
| 12 |
+
model_path = hf_hub_download(
|
| 13 |
+
repo_id="AngadSi/wellness-purchase-prediction-model",
|
| 14 |
+
filename="wellness_purchase_model.joblib",
|
| 15 |
+
repo_type="model"
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
model = joblib.load(model_path)
|
| 19 |
+
|
| 20 |
+
# UI inputs
|
| 21 |
+
age = st.number_input("Age", min_value=18, max_value=100, value=30)
|
| 22 |
+
income = st.number_input("Monthly Income", min_value=0, value=6000)
|
| 23 |
+
trips = st.number_input("Number of Trips", min_value=0, value=2)
|
| 24 |
+
pitch_score = st.slider("Pitch Satisfaction Score", 1, 100, 80)
|
| 25 |
+
|
| 26 |
+
if st.button("Predict"):
|
| 27 |
+
df = pd.DataFrame([{
|
| 28 |
+
"Age": age,
|
| 29 |
+
"MonthlyIncome": income,
|
| 30 |
+
"NumberOfTrips": trips,
|
| 31 |
+
"PitchSatisfactionScore": pitch_score
|
| 32 |
+
}])
|
| 33 |
+
|
| 34 |
+
pred = model.predict(df)[0]
|
| 35 |
+
prob = model.predict_proba(df)[0][1]
|
| 36 |
+
|
| 37 |
+
st.success(f"Prediction: {'Will Purchase' if pred == 1 else 'Will Not Purchase'}")
|
| 38 |
+
st.info(f"Purchase Probability: {round(prob, 2)}")
|