Download ExtraaLearningModelCustomerJourneySalesOpt.app.py from Odirile76/OMacha: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/spaces/Odirile76/OMacha/resolve/main/ExtraaLearningModelCustomerJourneySalesOpt.app.py
- Command line
-
hf download hf://spaces/Odirile76/OMacha/ExtraaLearningModelCustomerJourneySalesOpt.app.py
-
curl -L -o ExtraaLearningModelCustomerJourneySalesOpt.app.py https://huggingface.co/spaces/Odirile76/OMacha/resolve/main/ExtraaLearningModelCustomerJourneySalesOpt.app.py
1.17 kB
| import gradio as gr | |
| import joblib | |
| import pandas as pd | |
| model = joblib.load("ExtraaLearningModelCustomerJourneySalesOpt.joblib") | |
| def predict(age_group, occupation, channel, first, last): | |
| df = pd.DataFrame([{ | |
| "age_group": age_group, | |
| "current_occupation": occupation, | |
| "acquisition_channel": channel, | |
| "first_interaction": first, | |
| "last_activity": last, | |
| "journey": f"{channel} -> {first} -> {last}" | |
| }]) | |
| prob = model.predict_proba(df)[0][1] | |
| if prob >= 0.6: | |
| rec = "Invest more" | |
| elif prob >= 0.35: | |
| rec = "Test and optimize" | |
| else: | |
| rec = "Reduce spend" | |
| return prob, rec | |
| gr.Interface( | |
| fn=predict, | |
| inputs=[ | |
| gr.Dropdown(["<25","25-35","35-45","45-55","55-65"]), | |
| gr.Dropdown(["Professional","Student","Unemployed"]), | |
| gr.Dropdown(["Digital Media","Referral","Print Media 1","Print Media 2","Educational Channels"]), | |
| gr.Dropdown(["Website","Mobile App","Phone"]), | |
| gr.Dropdown(["Email Activity","Phone Activity","Website Activity"]) | |
| ], | |
| outputs=["number","text"], | |
| title="Customer Journey Optimization Model" | |
| ).launch() |