Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
from gradio_client import Client, handle_file
|
|
|
3 |
import matplotlib.pyplot as plt
|
4 |
import os
|
5 |
|
@@ -39,12 +40,25 @@ def stream_chat_with_rag(
|
|
39 |
|
40 |
|
41 |
def heatmap(top_n):
|
42 |
-
|
43 |
top_n= top_n,
|
44 |
-
api_name="/
|
45 |
)
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
# Create Gradio interface
|
50 |
with gr.Blocks(title="Reddit Election Analysis") as demo:
|
|
|
1 |
import gradio as gr
|
2 |
from gradio_client import Client, handle_file
|
3 |
+
import seaborn as sns
|
4 |
import matplotlib.pyplot as plt
|
5 |
import os
|
6 |
|
|
|
40 |
|
41 |
|
42 |
def heatmap(top_n):
|
43 |
+
pivot_table = client.predict(
|
44 |
top_n= top_n,
|
45 |
+
api_name="/get_heatmap_pivot_table"
|
46 |
)
|
47 |
+
|
48 |
+
plt.figure(figsize=(10, 8))
|
49 |
+
sns.heatmap(pivot_table,
|
50 |
+
cmap='YlOrRd',
|
51 |
+
cbar_kws={'label': 'Weighted Frequency'},
|
52 |
+
square=True)
|
53 |
+
|
54 |
+
plt.title(f'Top {top_n} Emotions vs Topics Weighted Frequency')
|
55 |
+
plt.xlabel('Topics')
|
56 |
+
plt.ylabel('Emotions')
|
57 |
+
plt.xticks(rotation=45, ha='right')
|
58 |
+
plt.tight_layout()
|
59 |
+
|
60 |
+
return plt.gcf()
|
61 |
+
|
62 |
|
63 |
# Create Gradio interface
|
64 |
with gr.Blocks(title="Reddit Election Analysis") as demo:
|