123ahmed commited on
Commit
9ff6c1d
·
verified ·
1 Parent(s): 402fadd

Upload 5 files

Browse files
Files changed (5) hide show
  1. app.py +57 -0
  2. le_col.pkl +3 -0
  3. lg.pkl +3 -0
  4. requirements.txt +4 -0
  5. std_col.pkl +3 -0
app.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import gradio as gr
3
+ import joblib
4
+
5
+
6
+ le=joblib.load('le_col.pkl')
7
+ std=joblib.load('std_col.pkl')
8
+ lg=joblib.load('lg.pkl')
9
+
10
+ le_col=['gender','education','region','loyalty_status','purchase_frequency','product_category']
11
+ std_col=['age','income','purchase_amount','promotion_usage','satisfaction_score']
12
+
13
+
14
+ def Prediction_will_purchase_again_Model(a,g,i,e,r,l,p,pp,c,u,s):
15
+ try:
16
+ input_data=pd.DataFrame({
17
+ 'age':[a],
18
+ 'gender':[g],
19
+ 'income':[i],
20
+ 'education':[e],
21
+ 'region':[r],
22
+ 'loyalty_status':[l],
23
+ 'purchase_frequency':[p],
24
+ 'purchase_amount':[pp],
25
+ 'product_category':[c],
26
+ 'promotion_usage':[u],
27
+ 'satisfaction_score':[s]
28
+
29
+ })
30
+ for col in le_col:
31
+ input_data[col]=le[col].transform(input_data[col])
32
+ input_data[std_col]=std.transform(input_data[std_col])
33
+ prediction=lg.predict(input_data)
34
+ if prediction==1:
35
+ return 'Yes'
36
+ else:
37
+ return 'No'
38
+ except Exception as e:
39
+ return str(e)
40
+ gr.Interface(
41
+ fn=Prediction_will_purchase_again_Model,
42
+ inputs=[
43
+ gr.Number(label='age'),
44
+ gr.Dropdown(['Male','Female'],label='gender'),
45
+ gr.Number(label='income'),
46
+ gr.Dropdown(['Bachelor', 'Masters', 'HighSchool', 'College'],label='education'),
47
+ gr.Dropdown(['East', 'West', 'South', 'North'],label='region'),
48
+ gr.Dropdown(['Gold', 'Regular', 'Silver'],label='loyalty_status'),
49
+ gr.Dropdown(['frequent', 'rare', 'occasional'],label='purchase_frequency'),
50
+ gr.Number(label='purchase_amount'),
51
+ gr.Dropdown(['Books', 'Clothing', 'Food', 'Electronics', 'Home', 'Beauty','Health'],label='product_category'),
52
+ gr.Number(label='promotion_usage'),
53
+ gr.Number(label='satisfaction_score')
54
+ ],
55
+ title='Prediction_will_purchase_again_Model',
56
+ outputs=gr.Textbox(label='Prediction')
57
+ ).launch()
le_col.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:09dc4a6f86055870f8653514863adc2de7c0e4fef088d7bbf580cb74c7fb5922
3
+ size 2197
lg.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6c48c5c92de3a83bfe875480244a0d6fc605843eaba7552b7213817aa18fc123
3
+ size 1455
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:6136f2f691832974e3696e79f05097332801f953b583c3a7eff3122d8738175f
3
+ size 1103