import gradio as gr import pandas as pd from sklearn import datasets import seaborn as sns import matplotlib.pyplot as plt from sklearn.preprocessing import LabelEncoder def findCorrelation(dataset, target): df = pd.read_csv(dataset.name) non_numeric_cols = df.select_dtypes('object').columns.tolist() if target in non_numeric_cols: label_encoder = LabelEncoder() df[non_numeric_col] = label_encoder.fit_transform(df[target]) d = df.corr()[target].to_dict() d.pop(target) keys = sorted(d.items(), key=lambda x: x[0], reverse=True) fig1 = plt.figure() hm = sns.heatmap(df.corr(), annot = True) hm.set(title = "Correlation matrix of dataset\n") fig2 = plt.figure() sns.regplot(x=df[keys[0][0]], y=df[target]) fig3 = plt.figure() sns.regplot(x=df[keys[1][0]], y=df[target]) fig4 = plt.figure() sns.regplot(x=df[keys[2][0]], y=df[target]) return d, fig1, fig2, fig3, fig4 demo = gr.Interface(fn=findCorrelation, inputs=[gr.File(), 'text'], outputs=[gr.Label(num_top_classes = 10), gr.Plot(), gr.Plot(), gr.Plot(), gr.Plot()], title="Find correlation") demo.launch(debug=True)