File size: 1,126 Bytes
a72fef3
06f0e1d
9457063
06f0e1d
8ace5ab
739a4ef
9457063
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13b1779
9457063
 
1862dc3
6aafa41
1862dc3
06f0e1d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import gradio as gr
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

def graphPlot():
    inp_list = [[13,0,8425333,'Asia'],
            [15,1,9712569,'Oceania'],
            [52,0,76039390,'Americas'],
            [2,0,637408000,'Asia'],
            [35,1,44310863,'Europe'],
            [20,0,3.72e+08,'Asia'],
            [45,1,171984000,'Americas']]
    mypredictions = [1,1,0,0,1,0,1]
    # creating a pandas dataframe
    df = pd.DataFrame(inp_list,columns=['week','diabetes_binary',
                                        'Population','Continent'])
      
    # Sorting by column 'week'
    df2=df.sort_values(by=['week'],ascending=True)
    
    X = list(df2.iloc[:, 0])
    Y = mypredictions
      
    # Plot the data using bar() method
    plt.plot(X, Y, 'o-g')
    plt.title("Diabetes prediction graph")
    plt.xlabel("week")
    plt.ylabel("diabetes_binary")
    for i in range(len(X)):
        b=str(X[i])+","+str(Y[i])
        plt.annotate(b, xy=(X[i], Y[i])) 
    # Show the plot
    plt.show()
    return plt
    
with gr.Blocks() as demo:
    gr.Plot(fn=graphPlot)
    
demo.launch()