import gradio as gr import pandas as pd import datasets import seaborn as sns import matplotlib.pyplot as plt df = datasets.load_dataset("merve/supersoaker-failures") df = df["train"].to_pandas() df.dropna(axis=0, inplace=True) df.drop(columns=["id"], inplace=True) def plot(df): plots = [] plt.scatter(df.measurement_13, df.measurement_15, c = df.loading,alpha=0.5) plt.savefig("scatter.png") plt.scatter(df.measurement_10, df.measurement_15, c = df.loading,alpha=0.5) plt.savefig("scatter_2.png") plt.scatter(df.measurement_14, df.measurement_15, c = df.loading,alpha=0.5) plt.savefig("scatter_3.png") plt.scatter(df.measurement_16, df.measurement_15, c = df.loading,alpha=0.5) plt.savefig("scatter_4.png") df['failure'].value_counts().plot(kind='bar') plt.savefig("bar.png") sns.distplot(df["loading"]) plt.savefig("loading_dist.png") sns.distplot(df["attribute_3"]) plt.savefig("attribute_3.png") sns.catplot(x='measurement_3', y='measurement_4', hue='failure', data=df, kind='violin') plt.savefig("swarmplot.png") sns.heatmap(df.select_dtypes(include="number").corr()) plt.savefig("corr.png") plots = ["corr.png","scatter.png", "bar.png", "loading_dist.png", "attribute_3.png", "swarmplot.png"] return plots inputs = [gr.Dataframe(label="Supersoaker Production Data")] outputs = [gr.Gallery(label="Profiling Dashboard").style(grid=(3,3))] gr.Interface(plot, inputs=inputs, outputs=outputs, examples=[df.head(100)], title="Supersoaker Failures Analysis Dashboard", description="This is a data analysis & visualization dashboard based on supersoaker failures data.").launch()