Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from ast import dump
|
2 |
+
from cProfile import label
|
3 |
+
from logging import PlaceHolder
|
4 |
+
from operator import mod
|
5 |
+
import pandas as pd
|
6 |
+
import numpy as np
|
7 |
+
import gradio as gr
|
8 |
+
from joblib import load,dump
|
9 |
+
|
10 |
+
def purchase(
|
11 |
+
UserID,Gender,Age,EstimatedSalary
|
12 |
+
):
|
13 |
+
|
14 |
+
model=load("purchased.jb")
|
15 |
+
|
16 |
+
data={
|
17 |
+
"UserID":[UserID],
|
18 |
+
"Gender":[Gender],
|
19 |
+
"Age":[Age],
|
20 |
+
"EstimatedSalary":[EstimatedSalary]
|
21 |
+
}
|
22 |
+
|
23 |
+
xin=pd.DataFrame(data)
|
24 |
+
purchased=model.predict(xin)
|
25 |
+
return purchased[0]
|
26 |
+
|
27 |
+
ui=gr.Interface(
|
28 |
+
fn=purchase,
|
29 |
+
inputs=[
|
30 |
+
gr.inputs.Textbox(placeholder="user_id",numeric=True,label="USER ID"),
|
31 |
+
gr.Radio(["Male","Female"],label="GENDER"),
|
32 |
+
gr.inputs.Textbox(placeholder="age",numeric=True,label="AGE"),
|
33 |
+
gr.inputs.Textbox(placeholder="estimated_salary",numeric=True,label="ESTIMATED SALARY"),
|
34 |
+
],
|
35 |
+
|
36 |
+
title="PURCHASED OR NOT ?",
|
37 |
+
outputs="text",
|
38 |
+
examples=[[15624510,"Male",19,19000,0],
|
39 |
+
[15694829,"Female",32,150000,1
|
40 |
+
]]
|
41 |
+
|
42 |
+
)
|
43 |
+
|
44 |
+
if __name__=="__main__":
|
45 |
+
ui.launch()
|