Spaces:
Runtime error
Runtime error
| 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) |