Spaces:
Sleeping
Sleeping
Ransaka
commited on
Commit
·
1cc7996
1
Parent(s):
4c8d160
Used cache
Browse files
app.py
CHANGED
@@ -10,18 +10,28 @@ import warnings
|
|
10 |
|
11 |
warnings.filterwarnings('ignore')
|
12 |
|
|
|
13 |
# cluster PNG file
|
14 |
image = Image.open('plots/clusters.png')
|
15 |
|
16 |
-
|
|
|
|
|
|
|
|
|
17 |
|
|
|
18 |
# Create a Streamlit app
|
19 |
-
st.set_page_config(page_title="Sinhala Embedding Space", page_icon=":bar_chart:")
|
20 |
|
21 |
# Define tabs
|
22 |
tabs = ["Clustering Results","Sentences Similarity"]
|
23 |
selected_tab = st.sidebar.radio("Select a Tab", tabs)
|
24 |
|
|
|
|
|
|
|
|
|
|
|
25 |
# Main content
|
26 |
if selected_tab == "Sentences Similarity":
|
27 |
sample_sentences = chart_data['Headline'].sample(10, random_state=1).tolist()
|
@@ -66,7 +76,7 @@ elif selected_tab == "Clustering Results":
|
|
66 |
with st.spinner('Loading Interactive Results...'):
|
67 |
# Display Altair chart
|
68 |
st.subheader("Interactive Chart")
|
69 |
-
chart =
|
70 |
st.altair_chart(chart, use_container_width=True)
|
71 |
|
72 |
# Dropdown functionality to update DataFrame
|
|
|
10 |
|
11 |
warnings.filterwarnings('ignore')
|
12 |
|
13 |
+
st.set_page_config(page_title="Sinhala Embedding Space", page_icon=":bar_chart:")
|
14 |
# cluster PNG file
|
15 |
image = Image.open('plots/clusters.png')
|
16 |
|
17 |
+
# Load data
|
18 |
+
@st.cache_data(persist='disk')
|
19 |
+
def load_data():
|
20 |
+
chart_data = pd.read_csv(r"data/top_cluster_dataset.csv",dtype={'Headline': str, 'x': np.float64, 'y': np.float64, 'labels': str})
|
21 |
+
return chart_data
|
22 |
|
23 |
+
chart_data = load_data()
|
24 |
# Create a Streamlit app
|
|
|
25 |
|
26 |
# Define tabs
|
27 |
tabs = ["Clustering Results","Sentences Similarity"]
|
28 |
selected_tab = st.sidebar.radio("Select a Tab", tabs)
|
29 |
|
30 |
+
@st.cache_data(persist='disk')
|
31 |
+
def get_altair_chart():
|
32 |
+
chart = alt.Chart(chart_data).mark_circle(size=60).encode(x='x', y='y', color='labels', tooltip=['Headline']).interactive()
|
33 |
+
return chart
|
34 |
+
|
35 |
# Main content
|
36 |
if selected_tab == "Sentences Similarity":
|
37 |
sample_sentences = chart_data['Headline'].sample(10, random_state=1).tolist()
|
|
|
76 |
with st.spinner('Loading Interactive Results...'):
|
77 |
# Display Altair chart
|
78 |
st.subheader("Interactive Chart")
|
79 |
+
chart = get_altair_chart()
|
80 |
st.altair_chart(chart, use_container_width=True)
|
81 |
|
82 |
# Dropdown functionality to update DataFrame
|