FahadAlam commited on
Commit
d4e49b0
1 Parent(s): 5ceed16

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -11
app.py CHANGED
@@ -4,25 +4,33 @@ from sklearn import datasets
4
  import seaborn as sns
5
  import matplotlib.pyplot as plt
6
 
7
- def findCorrelation():
8
- iris = datasets.load_iris()
9
- df = pd.DataFrame(data=iris.data, columns=iris.feature_names)
10
 
11
- df["target"] = iris.target
12
 
13
- correlation = df["sepal length (cm)"].corr(df["petal length (cm)"])
14
- corr = df.corr()
 
 
15
 
16
  fig1 = plt.figure()
17
  hm = sns.heatmap(df.corr(), annot = True)
18
- hm.set(xlabel='\nIRIS Flower Details', ylabel='IRIS Flower Details\t', title = "Correlation matrix of IRIS data\n")
19
 
20
  fig2 = plt.figure()
21
  # use the function regplot to make a scatterplot
22
- sns.regplot(x=df["sepal length (cm)"], y=df["sepal width (cm)"])
23
- plt.show()
 
 
 
 
 
 
 
24
 
25
- return fig1, fig2, plt
26
 
27
- demo = gr.Interface(fn=findCorrelation, inputs=[], outputs=[gr.Plot(), gr.Plot(), gr.Plot()], title="Find correlation")
28
  demo.launch()
 
4
  import seaborn as sns
5
  import matplotlib.pyplot as plt
6
 
7
+ def findCorrelation(dataset, target):
8
+ df = pd.read_csv(dataset)
 
9
 
10
+ df["target"] = target
11
 
12
+ d = df.corr()['target'].to_dict()
13
+ labels = sorted(d.items(), key=lambda x: x[1], reverse=True)
14
+
15
+ labels.pop("target")
16
 
17
  fig1 = plt.figure()
18
  hm = sns.heatmap(df.corr(), annot = True)
19
+ hm.set(title = "Correlation matrix of dataset\n")
20
 
21
  fig2 = plt.figure()
22
  # use the function regplot to make a scatterplot
23
+ sns.regplot(x=labels.keys()[0], y=df["target"])
24
+
25
+ fig3 = plt.figure()
26
+ # use the function regplot to make a scatterplot
27
+ sns.regplot(x=labels.keys()[1], y=df["target"])
28
+
29
+ fig4 = plt.figure()
30
+ # use the function regplot to make a scatterplot
31
+ sns.regplot(x=labels.keys()[2], y=df["target"])
32
 
33
+ return labels, fig1, fig2, fig3, fig4
34
 
35
+ demo = gr.Interface(fn=findCorrelation, inputs=[gr.File(), 'text'], outputs=[gr.Label(), gr.Plot(), gr.Plot(), gr.Plot(), gr.Plot()], title="Find correlation")
36
  demo.launch()