Spaces:
Configuration error
Configuration error
Download app.py from Chetan0001/README: direct link, hf CLI and curl.
- Browser
- Download file 948 Bytes
-
https://huggingface.co/spaces/Chetan0001/README/resolve/main/app.py
- Command line
-
hf download hf://spaces/Chetan0001/README/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Chetan0001/README/resolve/main/app.py
948 Bytes
| import streamlit as st | |
| import pandas as pd | |
| import numpy as np | |
| import joblib | |
| st.set_page_config(page_title="Conversion Predictor", layout="centered") | |
| st.title("🎯 Digital Marketing Conversion Predictor") | |
| # Load model and scaler | |
| model = joblib.load("rf_model.pkl") | |
| scaler = joblib.load("scaler.pkl") | |
| # UI input | |
| gender = st.selectbox("Gender", ["Male", "Female"]) | |
| age = st.slider("Age", 18, 70, 30) | |
| income = st.number_input("Annual Income (USD)", value=50000) | |
| # Feature engineering | |
| input_df = pd.DataFrame({ | |
| "Age": [age], | |
| "Income": [income], | |
| "Gender_Male": [1 if gender == "Male" else 0] | |
| }) | |
| # Scale | |
| input_scaled = scaler.transform(input_df) | |
| # Predict | |
| pred_prob = model.predict_proba(input_scaled)[0][1] | |
| prediction = model.predict(input_scaled)[0] | |
| # Output | |
| st.write(f"🔮 Conversion Probability: **{pred_prob:.2%}**") | |
| if prediction == 1: | |
| st.success("✅ Likely to Convert") | |
| else: | |
| st.warning("⚠️ Unlikely to Convert") | |