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