Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -3,9 +3,19 @@ import pandas as pd
|
|
| 3 |
from huggingface_hub import hf_hub_download
|
| 4 |
import joblib
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# Download and load the trained model
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Streamlit UI
|
| 11 |
st.title("Visit with Us - Purchase Prediction App")
|
|
@@ -63,11 +73,11 @@ input_data = pd.DataFrame([{
|
|
| 63 |
'NumberOfFollowups': num_followups,
|
| 64 |
'DurationOfPitch': duration_of_pitch
|
| 65 |
}])
|
| 66 |
-
|
| 67 |
|
| 68 |
# Predict button
|
| 69 |
if st.button("Predict"):
|
| 70 |
prediction = model.predict(input_data)[0]
|
| 71 |
-
|
| 72 |
st.subheader("Prediction Result:")
|
| 73 |
st.success(f"The customer is {'likely' if prediction == 1 else 'not likely'} to purchase the tourism package.")
|
|
|
|
| 3 |
from huggingface_hub import hf_hub_download
|
| 4 |
import joblib
|
| 5 |
|
| 6 |
+
# for logging
|
| 7 |
+
import logging
|
| 8 |
+
|
| 9 |
+
logging.basicConfig(level=logging.INFO)
|
| 10 |
+
logger = logging.getLogger(__name__)
|
| 11 |
+
|
| 12 |
# Download and load the trained model
|
| 13 |
+
@st.cache_resource
|
| 14 |
+
def load_model():
|
| 15 |
+
model_path = hf_hub_download(repo_id="lcsekar/tourism-project-model", filename="best_model_v1.joblib")
|
| 16 |
+
return joblib.load(model_path)
|
| 17 |
+
|
| 18 |
+
model = load_model()
|
| 19 |
|
| 20 |
# Streamlit UI
|
| 21 |
st.title("Visit with Us - Purchase Prediction App")
|
|
|
|
| 73 |
'NumberOfFollowups': num_followups,
|
| 74 |
'DurationOfPitch': duration_of_pitch
|
| 75 |
}])
|
| 76 |
+
logger.info(input_data)
|
| 77 |
|
| 78 |
# Predict button
|
| 79 |
if st.button("Predict"):
|
| 80 |
prediction = model.predict(input_data)[0]
|
| 81 |
+
logger.info(f"Prediction: {prediction}")
|
| 82 |
st.subheader("Prediction Result:")
|
| 83 |
st.success(f"The customer is {'likely' if prediction == 1 else 'not likely'} to purchase the tourism package.")
|