Plashkar commited on
Commit
9457063
·
1 Parent(s): 8ace5ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -11
app.py CHANGED
@@ -1,17 +1,39 @@
1
  import gradio as gr
2
  import numpy as np
 
3
  import pandas as pd
4
 
5
- demo = gr.Blocks()
6
- def fileRead(x):
7
- df = pd.read_csv('Plashkar/diabetes-predict-db')
8
- # Renaming DiabetesPedigreeFunction as DPF
9
- df = df.rename(columns={'DiabetesPedigreeFunction':'DPF'})
10
- return df
11
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  with demo:
13
- inp = gr.Textbox(placeholder="Enter a statement to complete")
14
- out1 = gr.Textbox()
15
- inp.change(fn=fileRead, inputs=inp,
16
- outputs=out1)
17
  demo.launch()
 
1
  import gradio as gr
2
  import numpy as np
3
+ import matplotlib.pyplot as plt
4
  import pandas as pd
5
 
6
+ demo = gr.Block
7
+ def graphPlot(inpX):
8
+ inp_list = [[13,0,8425333,'Asia'],
9
+ [15,1,9712569,'Oceania'],
10
+ [52,0,76039390,'Americas'],
11
+ [2,0,637408000,'Asia'],
12
+ [35,1,44310863,'Europe'],
13
+ [20,0,3.72e+08,'Asia'],
14
+ [45,1,171984000,'Americas']]
15
+ mypredictions = [1,1,0,0,1,0,1]
16
+ # creating a pandas dataframe
17
+ df = pd.DataFrame(inp_list,columns=['week','diabetes_binary',
18
+ 'Population','Continent'])
19
+
20
+ # Sorting by column 'week'
21
+ df2=df.sort_values(by=['week'],ascending=True)
22
+
23
+ X = list(df2.iloc[:, 0])
24
+ Y = mypredictions
25
+
26
+ # Plot the data using bar() method
27
+ plt.plot(X, Y, 'o-g')
28
+ plt.title("Diabetes prediction graph")
29
+ plt.xlabel("week")
30
+ plt.ylabel("diabetes_binary")
31
+ for i in range(len(X)):
32
+ b=str(X[i])+","+str(Y[i])
33
+ plt.annotate(b, xy=(X[i], Y[i]))
34
+ # Show the plot
35
+ return plt
36
+
37
  with demo:
38
+ gr.plot(fn=graphPolt)
 
 
 
39
  demo.launch()