File size: 1,149 Bytes
fac37fe
 
 
 
 
956127b
fac37fe
d4e49b0
956127b
 
43ca9c2
956127b
43ca9c2
c408675
956127b
e1564de
6448874
351771b
68c8a8e
43855cb
956127b
 
6448874
fac37fe
d4e49b0
cdfa50b
6448874
a34b177
d4e49b0
 
a34b177
d4e49b0
 
a34b177
50b9a9e
 
fac37fe
48f2e22
b58fdfd
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
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)