File size: 1,658 Bytes
a72fef3
06f0e1d
9457063
06f0e1d
8ace5ab
ed4e3f0
c48be04
9457063
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13b1779
c48be04
9457063
c48be04
 
 
 
 
 
 
 
 
 
ed4e3f0
7ee3ac3
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
41
42
43
44
45
46
47
48
49
import gradio as gr
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

def graphPlot(plot_type, r, month, countries, social_distancing):
    fig = plt.figure()
    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 fig
    
inputs = [
        gr.Dropdown(["Matplotlib", "Plotly", "Bokeh"], label="Plot Type"),
        gr.Slider(1, 4, 3.2, label="R"),
        gr.Dropdown(["January", "February", "March", "April", "May"], label="Month"),
        gr.CheckboxGroup(["USA", "Canada", "Mexico", "UK"], label="Countries", 
                         value=["USA", "Canada"]),
        gr.Checkbox(label="Social Distancing?"),
    ]
outputs = gr.Plot()

demo = gr.Interface(fn=graphPlot, inputs=inputs, outputs=outputs, cache_examples=True)
demo.launch(share=True)