{"id":249,"date":"2025-11-20T15:08:05","date_gmt":"2025-11-20T15:08:05","guid":{"rendered":"https:\/\/codetypingpro.com\/?p=249"},"modified":"2025-11-20T15:08:05","modified_gmt":"2025-11-20T15:08:05","slug":"38-real-world-python-projects-sentiment-analysis-dashboard","status":"publish","type":"post","link":"https:\/\/codetypingpro.com\/?p=249","title":{"rendered":"38 &#8211; Real-World Python Projects &#8211; Sentiment Analysis Dashboard"},"content":{"rendered":"\n<h6 class=\"wp-block-heading\"><\/h6>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Goal<\/strong><\/h3>\n\n\n\n<p>Create an interactive dashboard that analyzes text sentiment (positive\/negative\/neutral) from:<\/p>\n\n\n\n<p>\u2714 User input<br>\u2714 Tweets<br>\u2714 Reviews<br>\u2714 Uploaded CSV files<\/p>\n\n\n\n<p>Displays visual charts (pie chart, bar chart, timeline).<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83e\udde0 <strong>What the Project Will Do<\/strong><\/h1>\n\n\n\n<h3 class=\"wp-block-heading\">The dashboard can:<\/h3>\n\n\n\n<p>\u2714 Accept text input<br>\u2714 Analyze sentiment in real-time<br>\u2714 Upload a CSV of comments<br>\u2714 Process each comment using NLP<br>\u2714 Show counts of Positive, Neutral, Negative<br>\u2714 Show sentiment distribution graph<br>\u2714 Show average sentiment score<br>\u2714 Show word cloud (optional)<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83e\uddf0 <strong>Tech Stack<\/strong><\/h1>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Python<\/strong><\/li>\n\n\n\n<li><strong>TextBlob \/ NLTK \/ Transformers<\/strong><\/li>\n\n\n\n<li><strong>Streamlit<\/strong> (dashboard)<\/li>\n\n\n\n<li><strong>Matplotlib \/ Plotly<\/strong><\/li>\n\n\n\n<li><strong>Pandas<\/strong><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udcc1 Folder Structure<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>SentimentDashboard\/\n\u2502\u2500\u2500 app.py\n\u2502\u2500\u2500 requirements.txt\n\u2502\u2500\u2500 sample_reviews.csv\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udce6 requirements.txt<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>streamlit\npandas\ntextblob\nmatplotlib\nwordcloud\n<\/code><\/pre>\n\n\n\n<p>Install all:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install -r requirements.txt\n<\/code><\/pre>\n\n\n\n<p>or manually:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install streamlit textblob pandas matplotlib wordcloud\npython -m textblob.download_corpora\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83e\udde9 <strong>Full Working Sentiment Dashboard Code (app.py)<\/strong><\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>import streamlit as st\nimport pandas as pd\nfrom textblob import TextBlob\nimport matplotlib.pyplot as plt\n\nst.title(\"Sentiment Analysis Dashboard\")\nst.write(\"Analyze text sentiment in real-time\")\n\ndef analyze_sentiment(text):\n    score = TextBlob(text).sentiment.polarity\n    if score &gt; 0:\n        return \"Positive\", score\n    elif score &lt; 0:\n        return \"Negative\", score\n    else:\n        return \"Neutral\", score\n\n# --- Option 1: Single Text Input ---\nst.header(\"Single Text Sentiment\")\nuser_text = st.text_area(\"Enter text\")\n\nif st.button(\"Analyze\"):\n    sentiment, score = analyze_sentiment(user_text)\n    st.success(f\"Sentiment: {sentiment} (Score: {score})\")\n\n# --- Option 2: CSV Upload ---\nst.header(\"CSV Sentiment Analysis\")\nfile = st.file_uploader(\"Upload CSV with 'text' column\", type=&#91;'csv'])\n\nif file is not None:\n    df = pd.read_csv(file)\n    df&#91;\"Sentiment\"] = df&#91;\"text\"].apply(lambda x: analyze_sentiment(x)&#91;0])\n    df&#91;\"Score\"] = df&#91;\"text\"].apply(lambda x: analyze_sentiment(x)&#91;1])\n    st.write(df)\n\n    # Count sentiment values\n    counts = df&#91;\"Sentiment\"].value_counts()\n\n    # Plot\n    st.subheader(\"Sentiment Distribution\")\n    fig, ax = plt.subplots()\n    ax.pie(counts, labels=counts.index, autopct=\"%1.1f%%\")\n    st.pyplot(fig)\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\u25b6 Run the Dashboard<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>streamlit run app.py\n<\/code><\/pre>\n\n\n\n<p>Opens in browser:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;localhost:8501\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udcca <strong>Features in Dashboard<\/strong><\/h1>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. Sentiment Analyzer<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Positive<\/li>\n\n\n\n<li>Negative<\/li>\n\n\n\n<li>Neutral<\/li>\n\n\n\n<li>Shows sentiment score (-1 to +1)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. CSV Analysis<\/strong><\/h3>\n\n\n\n<p>Upload file like:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>text\n\"Great product\"\n\"Very bad service\"\n\"Okay, not good not bad\"\n<\/code><\/pre>\n\n\n\n<p>Dashboard shows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Table with sentiment<\/li>\n\n\n\n<li>Pie chart<\/li>\n\n\n\n<li>Score distribution<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. Graphs<\/strong><\/h3>\n\n\n\n<p>Optional additions:<\/p>\n\n\n\n<p>\u2b50 Bar chart<br>\u2b50 Word cloud<br>\u2b50 Sentiment over time<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Goal Create an interactive dashboard that analyzes text sentiment (positive\/negative\/neutral) from: \u2714 User input\u2714 Tweets\u2714 Reviews\u2714 Uploaded CSV files Displays visual charts (pie chart, bar chart, timeline). \ud83e\udde0 What the Project Will Do The dashboard can: \u2714 Accept text input\u2714 Analyze sentiment in real-time\u2714 Upload a CSV of comments\u2714 Process each comment using NLP\u2714 Show [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-249","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=249"}],"version-history":[{"count":1,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/249\/revisions"}],"predecessor-version":[{"id":250,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/249\/revisions\/250"}],"wp:attachment":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}