Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,7 @@ import seaborn as sns
|
|
| 6 |
import plotly.express as px
|
| 7 |
import plotly.io as pio
|
| 8 |
import plotly.graph_objects as go
|
|
|
|
| 9 |
|
| 10 |
# Set page configuration
|
| 11 |
st.set_page_config(layout="wide")
|
|
@@ -36,7 +37,7 @@ df = load_and_clean_data()
|
|
| 36 |
|
| 37 |
|
| 38 |
# Page navigation setup
|
| 39 |
-
page_names = [" GESI Overview", "Sentiment Analysis", "Discrimination Analysis", "Channel Analysis"]
|
| 40 |
page = st.sidebar.selectbox("Choose a page", page_names)
|
| 41 |
|
| 42 |
# Sidebar Filters
|
|
@@ -60,6 +61,64 @@ df_filtered = df[(df['Domain'].isin(domain_filter)) &
|
|
| 60 |
# Define a color palette for consistent visualization styles
|
| 61 |
color_palette = px.colors.sequential.Viridis
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
# Visualisation for Domain Distribution
|
| 65 |
def create_pie_chart(df, column, title):
|
|
@@ -191,7 +250,9 @@ def create_channel_discrimination_chart(df):
|
|
| 191 |
|
| 192 |
# Function for rendering dashboard
|
| 193 |
def render_dashboard(page, df_filtered):
|
| 194 |
-
if page == "
|
|
|
|
|
|
|
| 195 |
st.title(" GESI Overview Dashboard")
|
| 196 |
col1, col2 = st.columns(2)
|
| 197 |
with col1:
|
|
|
|
| 6 |
import plotly.express as px
|
| 7 |
import plotly.io as pio
|
| 8 |
import plotly.graph_objects as go
|
| 9 |
+
from run import run_pipeline
|
| 10 |
|
| 11 |
# Set page configuration
|
| 12 |
st.set_page_config(layout="wide")
|
|
|
|
| 37 |
|
| 38 |
|
| 39 |
# Page navigation setup
|
| 40 |
+
page_names = ["Analytics Dashboard for Domain Predictions", "GESI Overview", "Sentiment Analysis", "Discrimination Analysis", "Channel Analysis"]
|
| 41 |
page = st.sidebar.selectbox("Choose a page", page_names)
|
| 42 |
|
| 43 |
# Sidebar Filters
|
|
|
|
| 61 |
# Define a color palette for consistent visualization styles
|
| 62 |
color_palette = px.colors.sequential.Viridis
|
| 63 |
|
| 64 |
+
# Function to render the model prediction visualization page
|
| 65 |
+
def render_prediction_page():
|
| 66 |
+
st.title("Streamlit Analytics Dashboard for Model Predictions")
|
| 67 |
+
st.write("""
|
| 68 |
+
Welcome to the interactive analytics dashboard that brings to life the nuanced assessment of textual content.
|
| 69 |
+
Dive into the insightful world of language processing where each sentence you enter is meticulously evaluated
|
| 70 |
+
for its domain relevance and sentiment connotation.
|
| 71 |
+
Instant Analysis: Enter any text snippet and get immediate predictions with our sophisticated model that assesses content with nuanced precision.
|
| 72 |
+
Domain Identification: Discover the domain categorization of your text, providing clarity on the subject matter with a quantifiable domain score.
|
| 73 |
+
""")
|
| 74 |
+
|
| 75 |
+
# User input text area
|
| 76 |
+
user_input = st.text_area("Enter Text/Content here to analyze", height=150)
|
| 77 |
+
|
| 78 |
+
if st.button("Perform Contextual Analysis"):
|
| 79 |
+
# Use run_pipeline to get predictions
|
| 80 |
+
prediction = run_pipeline(user_input)
|
| 81 |
+
|
| 82 |
+
# Extract prediction details
|
| 83 |
+
domain_label = prediction.get("domain_label", "Unknown")
|
| 84 |
+
domain_score = prediction.get("domain_score", 0)
|
| 85 |
+
discrimination_label = prediction.get("discrimination_label", "Unknown")
|
| 86 |
+
discrimination_score = prediction.get("discrimination_score", 0)
|
| 87 |
+
|
| 88 |
+
# Visualization layout
|
| 89 |
+
col1, col2 = st.columns(2)
|
| 90 |
+
|
| 91 |
+
with col1:
|
| 92 |
+
st.markdown("#### Domain Label")
|
| 93 |
+
st.markdown(f"## {domain_label}")
|
| 94 |
+
st.progress(domain_score)
|
| 95 |
+
|
| 96 |
+
with col2:
|
| 97 |
+
st.markdown("#### Discrimination Label")
|
| 98 |
+
st.markdown(f"## {discrimination_label}")
|
| 99 |
+
st.progress(discrimination_score)
|
| 100 |
+
|
| 101 |
+
col3, col4 = st.columns(2)
|
| 102 |
+
|
| 103 |
+
with col3:
|
| 104 |
+
# Domain Score Gauge
|
| 105 |
+
fig_domain = go.Figure(go.Indicator(
|
| 106 |
+
mode="gauge+number",
|
| 107 |
+
value=domain_score,
|
| 108 |
+
domain={'x': [0, 1], 'y': [0, 1]},
|
| 109 |
+
title={'text': "Domain Score"},
|
| 110 |
+
gauge={'axis': {'range': [None, 1]}}))
|
| 111 |
+
st.plotly_chart(fig_domain, use_container_width=True)
|
| 112 |
+
|
| 113 |
+
with col4:
|
| 114 |
+
# Discrimination Score Gauge
|
| 115 |
+
fig_discrimination = go.Figure(go.Indicator(
|
| 116 |
+
mode="gauge+number",
|
| 117 |
+
value=discrimination_score,
|
| 118 |
+
domain={'x': [0, 1], 'y': [0, 1]},
|
| 119 |
+
title={'text': "Discrimination Score"},
|
| 120 |
+
gauge={'axis': {'range': [None, 1]}}))
|
| 121 |
+
st.plotly_chart(fig_discrimination, use_container_width=True)
|
| 122 |
|
| 123 |
# Visualisation for Domain Distribution
|
| 124 |
def create_pie_chart(df, column, title):
|
|
|
|
| 250 |
|
| 251 |
# Function for rendering dashboard
|
| 252 |
def render_dashboard(page, df_filtered):
|
| 253 |
+
if page == "Analytics Dashboard for Domain Predictions":
|
| 254 |
+
render_prediction_page()
|
| 255 |
+
elif page == "GESI Overview":
|
| 256 |
st.title(" GESI Overview Dashboard")
|
| 257 |
col1, col2 = st.columns(2)
|
| 258 |
with col1:
|