peter2000's picture
Update apps/sdg_pd.py
3b46d6c
raw
history blame
1.46 kB
import plotly.express as px
import streamlit as st
from sentence_transformers import SentenceTransformer
import umap.umap_ as umap
import pandas as pd
import os
def app():
st.title("SDG Embedding Visualisation")
with st.spinner("πŸ‘‘ load data"):
df_osdg = pd.read_csv("sdg_umap.csv", sep = "|")
#labels = [_lab_dict[lab] for lab in df_osdg['label'] ]
keys = list(df_osdg['keys'])
#docs = list(df_osdg['text'])
agree = st.checkbox('add labels')
if agree:
with st.spinner("πŸ‘‘ create visualisation"):
fig = px.scatter_3d(
df_osdg, x='coord_x', y='coord_y', z='coord_z',
color='labels',
opacity = .5, hover_data=[keys])
fig.update_scenes(xaxis_visible=False, yaxis_visible=False,zaxis_visible=False )
fig.update_traces(marker_size=4)
st.plotly_chart(fig)
else:
with st.spinner("πŸ‘‘ create visualisation"):
fig = px.scatter_3d(
df_osdg, x='coord_x', y='coord_y', z='coord_z',
opacity = .5, hover_data=[keys])
fig.update_scenes(xaxis_visible=False, yaxis_visible=False,zaxis_visible=False )
fig.update_traces(marker_size=4)
st.plotly_chart(fig)