File size: 1,349 Bytes
fac37fe
 
 
 
 
 
d4e49b0
43ca9c2
e42834f
a79a6a1
88a936b
 
 
 
a79a6a1
43ca9c2
e42834f
88a936b
a79a6a1
6448874
351771b
68c8a8e
ec76814
 
cdfa50b
6448874
fac37fe
d4e49b0
6448874
cdfa50b
 
6448874
fac37fe
cdfa50b
126b501
cdfa50b
 
d4e49b0
 
 
126b501
d4e49b0
cdfa50b
 
d4e49b0
 
126b501
ec76814
cdfa50b
ec76814
 
6448874
ec76814
fac37fe
d4e49b0
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import gradio as gr
import pandas as pd
from sklearn import datasets
import seaborn as sns
import matplotlib.pyplot as plt

def findCorrelation(dataset, target):
  
  print(dataset.name)
  print("\n")
  
  print(target)
  print(type(target))
  print(str(target))
  print("\n")
  
  df = pd.read_csv(dataset.name)
  print(df)
  print("\n")
  
  d = df.corr()[target].to_dict()
  d.pop(target)
  print(d)
  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")
  
  print("\n Fig 1")
    
  fig2 = plt.figure()
  # use the function regplot to make a scatterplot
  print(df[keys[0]])
  sns.regplot(x=df[keys[0]], y=df[target])
  print(df[keys[0]])  
  print("\n Fig 2")
  
  fig3 = plt.figure()
  # use the function regplot to make a scatterplot
  sns.regplot(x=df[keys[1]], y=df[target])

  print("\n Fig 3")

  fig4 = plt.figure()
  # use the function regplot to make a scatterplot
  sns.regplot(x=df[keys[2]], y=df[target])
  
  print("\n Fig 4")
  
  labels = {key: d[key] for key in keys[10]}
  
  return labels, fig1, fig2, fig3, fig4

demo = gr.Interface(fn=findCorrelation, inputs=[gr.File(), 'text'], outputs=[gr.Label(), gr.Plot(), gr.Plot(), gr.Plot(), gr.Plot()], title="Find correlation")
demo.launch(debug=True)