Spaces:
No application file

File size: 1,165 Bytes
80bc2fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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()