123ahmed commited on
Commit
d72edec
·
verified ·
1 Parent(s): c59866a

Upload 5 files

Browse files
Files changed (5) hide show
  1. app.py +61 -0
  2. le_col.pkl +3 -0
  3. model.pkl +3 -0
  4. requirements.txt +4 -0
  5. std_col.pkl +3 -0
app.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import pandas as pd
3
+ import gradio as gr
4
+ import joblib as jp
5
+
6
+
7
+
8
+
9
+ model=jp.load(r'C:\Users\ahmed\Desktop\Data Analysis Project Saudia Arabia\1th Project1\model.pkl')
10
+ std = jp.load(r"C:\Users\ahmed\Desktop\Data Analysis Project Saudia Arabia\1th Project1\std_col.pkl")
11
+ le = jp.load(r"C:\Users\ahmed\Desktop\Data Analysis Project Saudia Arabia\1th Project1\le_col.pkl")
12
+
13
+ le_col=['gender','education','region','purchase_frequency','product_category']
14
+ std_col=['age','income','purchase_amount']
15
+
16
+ def Customer_Predction_Model(ag,gender,income,edu,reg,loy,pr,pu,prod,prom,sts):
17
+ try:
18
+ input_data=pd.DataFrame({
19
+ 'age':[ag],
20
+ 'gender':[gender],
21
+ 'income':[income],
22
+ 'education':[edu],
23
+ 'region':[reg],
24
+ 'loyalty_status':[loy],
25
+ 'purchase_frequency':[pr],
26
+ 'purchase_amount':[pu],
27
+ 'product_category':[prod],
28
+ 'promotion_usage':[prom],
29
+ 'satisfaction_score':[sts]
30
+ })
31
+ for col in le_col:
32
+ input_data[col]=le[col].transform(input_data[col])
33
+ input_data[std_col]=std.transform(input_data[std_col])
34
+ prediction=model.predict(input_data)
35
+ if prediction[0]==0:
36
+ return 'No'
37
+ else:
38
+ return 'Yes'
39
+
40
+ except Exception as e:
41
+ return str(e)
42
+ gr.Interface(
43
+ fn=Customer_Predction_Model,
44
+ inputs=[
45
+ gr.Number(label='age'),
46
+ gr.Dropdown(['Male','Female'],label='gender'),
47
+ gr.Number(label='income'),
48
+ gr.Dropdown(['College','Bachelor','HighSchool','Masters'],label='education'),
49
+ gr.Dropdown(['East','West','South','North'],label='region'),
50
+ gr.Number(label='loyalty_status'),
51
+ gr.Dropdown(['rare','occasional','frequent'],label='purchase_frequency'),
52
+ gr.Number(label='purchase_amount'),
53
+ gr.Dropdown(['Electronics','Clothing','Books','Food','Health','Home','Beauty'],label='product_category'),
54
+ gr.Number(label='promotion_usage'),
55
+ gr.Number(label='satisfaction_score')
56
+
57
+ ],
58
+ outputs=gr.Textbox(label='Prediction'),
59
+ title='Customer Purchase Anticipation Prediction Model'
60
+
61
+ ).launch()
le_col.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:269984723101905983d864c4488497b844208316dd7e62680bb275a94e757af1
3
+ size 1874
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:197258fe7506245944b9f20c04accb33dc6d55d01fe8d0f3bd71945927847378
3
+ size 23745
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio
2
+ pandas
3
+ joblib
4
+ scikit-learn
std_col.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:de9c21ea3f4bcf71652cb38958321e388525fcc4534e08b43fa3e12259eb3509
3
+ size 1007