kedhar4's picture
Upload app.py with huggingface_hub
600b5ae verified
Raw
History Blame Contribute Delete
926 Bytes
# Streamlit app supporting RF and XGB models
import streamlit as st
import pandas as pd, os, joblib
st.title('Tourism Package Prediction - Demo (RF & XGB)')
MODEL_RF = '/data/output/best_model.joblib'
MODEL_XGB = '/data/output/best_xgb.joblib'
models = {}
if os.path.exists(MODEL_RF):
models['RandomForest'] = joblib.load(MODEL_RF)
if os.path.exists(MODEL_XGB):
models['XGBoost'] = joblib.load(MODEL_XGB)
if not models:
st.error('No model artifacts found. Place best_model.joblib or best_xgb.joblib in /mnt/data/output/')
st.stop()
choice = st.selectbox('Choose model', list(models.keys()))
model = models[choice]
st.write('Selected model:', choice)
st.write('Upload a CSV (features only) to predict:')
uploaded = st.file_uploader('Input CSV', type=['csv'])
if uploaded:
df = pd.read_csv(uploaded)
st.write('Preview:', df.head())
preds = model.predict(df)
st.write('Predictions:', preds)