Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
9 |
-
df = pd.DataFrame(data=iris.data, columns=iris.feature_names)
|
10 |
|
11 |
-
df["target"] =
|
12 |
|
13 |
-
|
14 |
-
|
|
|
|
|
15 |
|
16 |
fig1 = plt.figure()
|
17 |
hm = sns.heatmap(df.corr(), annot = True)
|
18 |
-
hm.set(
|
19 |
|
20 |
fig2 = plt.figure()
|
21 |
# use the function regplot to make a scatterplot
|
22 |
-
sns.regplot(x=
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
-
return fig1, fig2,
|
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()
|