Spaces:
Build error
Build error
| import streamlit as st | |
| st.write("β NEW APP VERSION LOADED - COMMIT TEST") | |
| import json | |
| import joblib | |
| import pandas as pd | |
| import streamlit as st | |
| from huggingface_hub import hf_hub_download | |
| # ================= CONFIG ================= | |
| MODEL_REPO = "Prashantbhat1607/wellness-tourism-model" | |
| MODEL_FILE = "model.joblib" | |
| META_FILE = "model_meta.json" | |
| # ========================================== | |
| st.set_page_config(page_title="Wellness Tourism Predictor", layout="centered") | |
| st.title("ποΈ Wellness Tourism Purchase Predictor") | |
| st.write("Predict whether a customer will purchase the Wellness Tourism Package.") | |
| def load_model_and_meta(): | |
| model_path = hf_hub_download( | |
| repo_id=MODEL_REPO, | |
| filename=MODEL_FILE, | |
| repo_type="model" | |
| ) | |
| meta_path = hf_hub_download( | |
| repo_id=MODEL_REPO, | |
| filename=META_FILE, | |
| repo_type="model" | |
| ) | |
| model = joblib.load(model_path) | |
| with open(meta_path, "r") as f: | |
| meta = json.load(f) | |
| return model, meta | |
| model, meta = load_model_and_meta() | |
| features = meta["features"] | |
| cat_cols = set(meta["categorical_cols"]) | |
| num_cols = set(meta["numeric_cols"]) | |
| st.subheader("Enter customer details") | |
| inputs = {} | |
| for col in features: | |
| if col in cat_cols: | |
| inputs[col] = st.text_input(col, value="Unknown") | |
| else: | |
| inputs[col] = st.number_input(col, value=0.0) | |
| if st.button("Predict"): | |
| X = pd.DataFrame([inputs], columns=features) | |
| proba = model.predict_proba(X)[0][1] | |
| pred = int(proba >= 0.5) | |
| st.success( | |
| f"Prediction: {'β Will Purchase' if pred==1 else 'β Will NOT Purchase'}" | |
| ) | |
| st.write(f"Probability of purchase: **{proba:.3f}**") | |