Graziela commited on
Commit
c4655dc
·
1 Parent(s): 9a1a88b

Upload app correcao

Browse files
Files changed (1) hide show
  1. app.py +22 -2
app.py CHANGED
@@ -5,15 +5,32 @@ Automatically generated by Colaboratory.
5
 
6
  Original file is located at
7
  https://colab.research.google.com/drive/1I-y23tTTs_aMjSYwPa3Fk8Ywz8H8ZUgl
 
 
8
  """
9
 
 
 
 
 
10
  import gradio as gr
11
  import joblib as jb
12
 
13
  def predict(sex, age, hypertension, heart_disease, ever_married, work_type, Residence_type, avg_glucose_level, bmi, smoking_status):
14
  model = jb.load('model.pkl')
 
 
 
 
 
 
 
 
 
 
15
 
16
- p = model.predict_proba({{sex, age, hypertension, heart_disease, ever_married, work_type, Residence_type, avg_glucose_level, bmi, smoking_status}})[0]
 
17
 
18
  return {"Não terá AVC": p[0], "Terá AVC": p[1]}
19
 
@@ -29,4 +46,7 @@ demo = gr.Interface(fn=predict,
29
  "number",
30
  gr.Dropdown(choices=["Nunca fumou", "Fuma"], type="index"),
31
  ],
32
- outputs="label")
 
 
 
 
5
 
6
  Original file is located at
7
  https://colab.research.google.com/drive/1I-y23tTTs_aMjSYwPa3Fk8Ywz8H8ZUgl
8
+
9
+ #**GRADIO**
10
  """
11
 
12
+ !pip install -q gradio
13
+
14
+ !pip install joblib
15
+
16
  import gradio as gr
17
  import joblib as jb
18
 
19
  def predict(sex, age, hypertension, heart_disease, ever_married, work_type, Residence_type, avg_glucose_level, bmi, smoking_status):
20
  model = jb.load('model.pkl')
21
+ sex = str(sex)
22
+ age = int(age)
23
+ hypertension = str(hypertension)
24
+ heart_disease = str(heart_disease)
25
+ ever_married = str(ever_married)
26
+ work_type = str(work_type)
27
+ Residence_type = int(Residence_type)
28
+ avg_glucose_level = float(avg_glucose_level )
29
+ bmi = float(bmi)
30
+ smoking_status = str(smoking_status)
31
 
32
+
33
+ p = model.predict({{sex, age, hypertension, heart_disease, ever_married, work_type, Residence_type, avg_glucose_level, bmi, smoking_status}})[0]
34
 
35
  return {"Não terá AVC": p[0], "Terá AVC": p[1]}
36
 
 
46
  "number",
47
  gr.Dropdown(choices=["Nunca fumou", "Fuma"], type="index"),
48
  ],
49
+ outputs="label")
50
+
51
+
52
+ demo.launch(share=True)