Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,14 +7,15 @@ from pycaret.regression import *
|
|
7 |
cvr_saved = load_model('pred_cvr')
|
8 |
|
9 |
def predict_cvr(xyz_campaign_id, gender, age, Impressions, Clicks,
|
10 |
-
Total_Conversion, interest):
|
11 |
-
path = "KAG_conversion_data.csv"
|
12 |
-
df = pd.read_csv(path)
|
13 |
-
df.drop(["ad_id", "fb_campaign_id", "Spent","Approved_Conversion"],axis=1, inplace = True)
|
14 |
-
df = pd.DataFrame.from_dict({'xyz_campaign_id': [xyz_campaign_id], 'gender': [gender], 'age': [age], 'Impressions': [Impressions],
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
18 |
|
19 |
xyz_campaign_id = gr.inputs.Dropdown(['campaign_a', 'campaign_b', 'campaign_c'], label="xyz_campaign_id -> an ID associated with each ad campaign of XYZ company")
|
20 |
gender = gr.inputs.Dropdown(['M', 'F'], label = "gender -> gender of the person to whom the add is shown")
|
|
|
7 |
cvr_saved = load_model('pred_cvr')
|
8 |
|
9 |
def predict_cvr(xyz_campaign_id, gender, age, Impressions, Clicks,
|
10 |
+
Total_Conversion, interest):
|
11 |
+
path = "KAG_conversion_data.csv"
|
12 |
+
df = pd.read_csv(path)
|
13 |
+
df.drop(["ad_id", "fb_campaign_id", "Spent","Approved_Conversion"],axis=1, inplace = True)
|
14 |
+
df = pd.DataFrame.from_dict({'xyz_campaign_id': [xyz_campaign_id], 'gender': [gender], 'age': [age], 'Impressions': [Impressions],
|
15 |
+
'Clicks': [Clicks], 'Total_Conversion': [Total_Conversion], 'interest': [interest]})
|
16 |
+
df["xyz_campaign_id"].replace({916:"campaign_a",936:"campaign_b",1178:"campaign_c"}, inplace=True)
|
17 |
+
pred = cvr_saved.predict(df).tolist()[0]
|
18 |
+
return 'Conversion Rate : '+str(pred)
|
19 |
|
20 |
xyz_campaign_id = gr.inputs.Dropdown(['campaign_a', 'campaign_b', 'campaign_c'], label="xyz_campaign_id -> an ID associated with each ad campaign of XYZ company")
|
21 |
gender = gr.inputs.Dropdown(['M', 'F'], label = "gender -> gender of the person to whom the add is shown")
|