A newer version of the Streamlit SDK is available: 1.56.0
Musora Sentiment Analysis Dashboard
A comprehensive, interactive Streamlit dashboard for visualizing sentiment analysis results from multiple data sources: social media comments (Facebook, Instagram, YouTube, Twitter) and Musora internal app comments across Musora brands (Drumeo, Pianote, Guitareo, Singeo).
Features
Main Dashboard
- Overall sentiment distribution with interactive pie charts and gauge indicators
- Sentiment analysis by brand (Drumeo, Pianote, Musora) with stacked bar charts
- Sentiment analysis by platform (Facebook, Instagram, etc.) with percentage distributions
- Intent analysis showing multi-label intent distributions (praise, question, request, etc.)
- Cross-dimensional heatmaps showing negative sentiment by brand and platform
- Reply requirements analysis with urgency breakdown
- Language distribution analysis
- Temporal trends with customizable time granularity (daily, weekly, monthly)
- Hierarchical sunburst visualization for brand > platform > sentiment
Sentiment Analysis Page
- Multi-sentiment filtering - Filter by any combination of sentiments (positive, negative, neutral, etc.) to analyze both good and bad performance
- Intent filtering - Filter contents by specific user intents (question, praise, feedback_negative, etc.)
- Dynamic severity scoring - Ranks contents based on selected sentiments, adapts calculations to your filter choices
- Advanced ranking controls - Customize with minimum comment thresholds and multiple dynamic sort options
- Sort options - Severity Score (balanced), Sentiment %, Sentiment Count (absolute), or Total Comments (volume)
- Engagement scatter plot showing relationship between comment volume and sentiment
- Thumbnail display for Musora internal app content (visual content previews)
- Detailed content analysis with sentiment and intent distributions for each content
- AI-Powered Analysis - Optional AI-generated insights and recommendations for each content
- View filtered comments for each content with expandable sections
- Actionable insights and recommendations based on sentiment patterns
- Export functionality to download results as CSV with dynamic columns
Reply Required Page
- Prioritized comment queue with urgency indicators (Urgent, High, Medium, Low)
- Smart filtering by priority, platform, brand, and intent
- Pagination for easy navigation through large comment lists
- Comment cards showing full context (author, timestamp, sentiment, intent)
- Original and translated text with expandable view for non-English comments
- Reply requirements by content showing which contents need most attention
- Export functionality for team collaboration or CRM import
Architecture
visualization/
βββ app.py # Main Streamlit application
βββ config/
β βββ viz_config.json # Configuration for colors, settings, queries
βββ data/
β βββ data_loader.py # Snowflake data loading with caching
βββ utils/
β βββ data_processor.py # Data aggregation and processing
β βββ metrics.py # Metrics calculation (KPIs, scores)
βββ components/
β βββ dashboard.py # Main dashboard page
β βββ sentiment_analysis.py # Comprehensive sentiment analysis page
β βββ reply_required.py # Reply management page
βββ visualizations/
β βββ sentiment_charts.py # Sentiment visualization functions
β βββ distribution_charts.py # Distribution visualization functions
β βββ content_cards.py # Display components and cards
βββ requirements.txt # Python dependencies
βββ README.md # This file
Installation
Prerequisites
- Python 3.8+
- Snowflake account with access to sentiment analysis data
- Required environment variables in parent
.envfile:SNOWFLAKE_USERSNOWFLAKE_PASSWORDSNOWFLAKE_ACCOUNTSNOWFLAKE_ROLESNOWFLAKE_DATABASESNOWFLAKE_WAREHOUSESNOWFLAKE_SCHEMA
Setup
- Navigate to the visualization directory:
cd visualization
- Install dependencies:
pip install -r requirements.txt
- Ensure parent
.envfile is properly configured with Snowflake credentials
Usage
Running the Dashboard
From the visualization directory:
streamlit run app.py
The dashboard will open in your default browser at http://localhost:8501
Navigation
Use the sidebar to:
- Select pages (Dashboard, Sentiment Analysis, Reply Required)
- Apply global filters by platform, brand, sentiment, and date range
- Reload data to fetch latest updates from Snowflake
- View data information (record count, last update time)
Filtering Data
Select desired filters in the sidebar:
- Platforms: Filter by data source (Facebook, Instagram, YouTube, Twitter, musora_app)
- Brands: Filter by Musora brand (Drumeo, Pianote, Guitareo, Singeo, Musora)
- Sentiments: Filter by sentiment polarity
- Date Range: Filter by comment timestamp
Click "Apply Filters" to update visualizations
Click "Reset Filters" to clear all filters
Exporting Data
Each page provides export functionality:
- Sentiment Analysis: Download top N contents as CSV with dynamic columns based on active filters
- Reply Required: Download filtered comments as CSV
Configuration
Color Schemes
Edit config/viz_config.json to customize:
- Sentiment colors: Colors for each sentiment polarity
- Intent colors: Colors for each intent category
- Platform colors: Brand colors for each platform
- Brand colors: Colors for each Musora brand
Dashboard Settings
Configure in viz_config.json:
default_date_range_days: Default date range for filteringmax_comments_display: Maximum comments to display per pagechart_height: Default height for chartstop_n_contents: Number of contents to show in poor sentiment page
Data Query
The Snowflake query is configured in viz_config.json:
"snowflake": {
"query": "SELECT s.*, c.CHANNEL_NAME as BRAND, c.MESSAGE as CONTENT_DESCRIPTION, c.PERMALINK_URL FROM SOCIAL_MEDIA_DB.ML_FEATURES.COMMENT_SENTIMENT_FEATURES s JOIN SOCIAL_MEDIA_DB.CORE.DIM_CONTENT c ON s.CONTENT_SK = c.CONTENT_SK"
}
Extending the Dashboard
Adding New Pages
- Create a new component file in
components/:
# components/new_page.py
def render_new_page(df):
st.title("New Page")
# Your page logic here
- Import and add to navigation in
app.py:
from components.new_page import render_new_page
# Add to page selection
page = st.radio("Select Page", [..., "New Page"])
# Add to page rendering
elif page == "New Page":
render_new_page(df)
Adding New Visualizations
Add visualization function to appropriate module:
visualizations/sentiment_charts.pyfor sentiment-related chartsvisualizations/distribution_charts.pyfor distribution charts
Use the function in page components
Example:
def create_new_chart(df, title="New Chart"):
fig = go.Figure(...)
return fig
Adding New Metrics
Add calculation methods to utils/metrics.py:
@staticmethod
def calculate_new_metric(df):
# Your metric calculation
return metric_value
Customizing Card Displays
Modify display methods in visualizations/content_cards.py:
@staticmethod
def display_custom_card(data):
# Your custom card layout
pass
Data Schema
The dashboard expects the following columns from Snowflake:
Required Columns
comment_sk: Unique comment identifiercomment_id: Comment IDoriginal_text: Original comment textplatform: Social media platformbrand: Musora brand namesentiment_polarity: Sentiment classification (very_positive, positive, neutral, negative, very_negative)intent: Comma-separated intent labelsrequires_reply: Boolean indicating if reply is neededcontent_sk: Content identifiercontent_description: Description of the contentpermalink_url: URL to the original content
Optional Columns
comment_timestamp: When comment was postedprocessed_at: When sentiment analysis was performedtranslated_text: English translation for non-English commentsdetected_language: Detected language of commentis_english: Boolean indicating if comment is in Englishsentiment_confidence: Confidence level of sentiment analysisauthor_name: Comment author namechannel_name: Channel namethumbnail_url: Content thumbnail URL (for Musora internal app content)parent_comment_id: ID of parent comment (for replies)parent_comment_text: Text of parent comment (for reply context)
Performance Optimization
Caching
- Data loading is cached for 5 minutes using
@st.cache_data - Clear cache using "Reload Data" button in sidebar
Pagination
- Comments requiring reply are paginated (10 per page)
- Reduces memory usage and improves rendering speed
Filtering
- Apply filters to reduce dataset size before visualization
- Filters are applied efficiently using pandas operations
Troubleshooting
Connection Issues
- Verify Snowflake credentials in parent
.envfile - Check network connectivity to Snowflake
- Ensure correct database, schema, and table names
No Data Displayed
- Check if Snowflake query returns data
- Verify column names match expected schema
- Check applied filters - try resetting them
Slow Performance
- Reduce date range in filters
- Use "Apply Filters" to work with smaller datasets
- Consider adding database indexes on frequently filtered columns
Visualization Errors
- Check for missing or null values in data
- Verify data types match expected types (dates, booleans, etc.)
- Review browser console for JavaScript errors
Best Practices
- Regular Data Updates: Reload data periodically to see latest comments
- Use Filters: Apply filters to focus on specific segments
- Export Insights: Download CSV reports for offline analysis
- Monitor Reply Queue: Check "Reply Required" page daily
- Track Trends: Use temporal visualizations to identify patterns
- Prioritize Urgent: Address urgent replies (negative sentiment) first
Support
For issues or feature requests:
- Check the troubleshooting section
- Review configuration files for correct settings
- Consult the main project README for sentiment analysis pipeline details
Version History
v1.3 (Current)
Comprehensive Sentiment Analysis Page Redesign
- Renamed "Poor Sentiment Contents" to "Sentiment Analysis" page
- NEW: Multi-Sentiment Filtering - Filter by any combination of sentiments (positive, negative, neutral, very_positive, very_negative)
- NEW: Intent Filtering - Filter contents by specific user intents (question, praise, feedback_negative, request, etc.)
- Filter Status Indicator - Visual feedback showing when filters are active
Dynamic Ranking & Calculations
- Dynamic severity scoring - Automatically calculates based on selected sentiments (not just negative)
- Dynamic metrics - Sentiment percentages and counts adapt to your filter selection
- Sort options now work with any sentiment combination
Enhanced User Experience
- Summary statistics that dynamically adapt to filters
- Contextual explanations that change based on selected sentiments
- Export with dynamic columns based on active filters
- Backward compatible - works like original when no filters selected
New Use Cases Enabled
- Analyze high-performing content (filter by positive sentiments)
- Identify successful patterns (combine sentiment + intent filters)
- Compare sentiment types side-by-side
- Focus on specific user behaviors
v1.2
- Multi-source data support - Integrated Musora internal app comments alongside social media
- Smart severity scoring - Content ranking now balances sentiment % with comment volume
- Advanced ranking controls - Min comments filter and multiple sort options (severity, %, count, volume)
- Thumbnail display - Visual content previews for Musora internal app content
- Platform disambiguation - Renamed internal platform to "musora_app" to differentiate from "musora" brand
- Improved chart stability - Fixed duplicate chart ID errors with unique keys
- Enhanced data schema - Added support for thumbnail_url and parent comment fields
v1.1
- AI-Powered Agents - ContentSummaryAgent for intelligent comment analysis
- AI Analysis button on Sentiment Analysis page
- LLM Helper with OpenAI API integration
- Modular agent architecture ready for expansion
v1.0
- Initial release
- Main dashboard with comprehensive visualizations
- Sentiment contents analysis page
- Reply required management page
- Global filtering and export functionality
- Plotly-based interactive visualizations
- Modular, extensible architecture