!R !Python !Dash
This project demonstrates an end-to-end data analysis pipeline that processes social media data (tweets) and presents the findings in an interactive web dashboard. The core data processing is performed in R, simulating a MapReduce workflow for efficient, parallelized analysis. The resulting insights are then visualized using a Python Dash application.
The primary goal is to showcase a full data lifecycle: from raw data generation and cleaning to distributed processing and final visualization.
(Suggestion: Take a screenshot of your running dashboard, save it in the project directory as dashboard_preview.png, and replace the line below with !Dashboard Preview)
A live preview of the dashboard will appear here.
- Interactive Visualizations: The dashboard provides dynamic charts for exploring trends and patterns in the data.
- MapReduce Simulation: Leverages R's
parallelandforeachlibraries to simulate a distributed MapReduce architecture, breaking down large analysis tasks into parallel map and reduce steps. - Comprehensive Analysis:
- Text Analysis: Identifies the most frequent words in the dataset.
- User Engagement: Ranks users by their total engagement (likes + retweets).
- Sentiment Analysis: Tracks the daily average sentiment score over time.
- Key Performance Indicators (KPIs): A summary panel displays high-level metrics like total tweets, unique users, and average engagement.
The project follows a clear, multi-stage workflow:
- Data Generation (Optional): A sample dataset of tweets is generated using an R script (
01_generate_sample_data.R). - Data Preprocessing: The raw text data is cleaned and standardized in R to prepare it for analysis. This includes removing punctuation, converting to lowercase, and handling special characters.
- MapReduce Processing (R): The core analysis is performed using three simulated MapReduce jobs:
- Job 1: Word Count: Counts the frequency of each word across all tweets.
- Job 2: Daily Sentiment: Calculates the average sentiment score for each day.
- Job 3: User Engagement: Aggregates the total likes and retweets for each user.
- Data Persistence: The results from the MapReduce jobs are saved as
.csvfiles. - Dashboard Visualization (Python): A Python script (
full_dashboard.py) reads the processed.csvfiles and uses the Dash framework to build and serve an interactive web dashboard.
Follow these instructions to get the project running on your local machine.
Make sure you have the following software installed:
- Git
- R (version 4.0.0 or newer) and an IDE like RStudio
- Python (version 3.8 or newer) and
pip
git clone https://github.com/your-username/social-media-dashboard.git
cd social-media-dashboard(Replace your-username with your actual GitHub username.)
The Python dashboard relies on data generated by the R scripts. You must run them to create the necessary .csv files.
-
Generate Sample Data (First time only):
- Open
scripts/01_generate_sample_data.Rin RStudio. - Run the script. This will create a
raw_tweets.csvfile in your project's root directory.
- Open
-
Install R Packages:
- Open any of the R scripts and install the required packages listed at the top (e.g.,
dplyr,parallel,foreach,syuzhet). You can do this by runninginstall.packages("package_name")in the R console.
- Open any of the R scripts and install the required packages listed at the top (e.g.,
-
Run the Processing Scripts in Order: Execute the following scripts sequentially. Each script performs a specific task and prepares data for the next stage.
Script Purpose Output Files 01_preprocessing.RCleans the raw tweet text. tweets_cleaned.csv03_data_preparation_for_mapreduce.RPrepares the cleaned data for the MapReduce jobs. (Intermediate step) 04_mapreduce_simulation.RRuns the three core MapReduce jobs for word count, sentiment, and user stats. mapreduce_word_count.csv,mapreduce_daily_sentiment.csv,mapreduce_user_stats.csv05_sentiment_analysis.R(Optional)Performs a more advanced sentiment and emotion analysis using different lexicons. sentiment_results.csvAfter running these, your project directory will contain all the
.csvfiles needed for the dashboard.
It is highly recommended to use a Python virtual environment to manage dependencies.
# Create a virtual environment named 'venv'
python -m venv venv
# Activate the virtual environment
# On Windows:
.\venv\Scripts\activate
# On macOS/Linux:
# source venv/bin/activate
# Install the required Python packages
pip install -r requirements.txtWith the data generated and the Python environment ready, you can now start the web application.
python full_dashboard.pyYou will see a message in your terminal with a local URL. Open your web browser and navigate to:
You should now see the interactive Social Media Analysis Dashboard!
SocialMediaProject/
├── scripts/
│ ├── 01_generate_sample_data.R # Generates raw sample data
│ ├── 01_preprocessing.R # Cleans the raw data
│ ├── 03_data_preparation_for_mapreduce.R # Prepares data for MapReduce
│ ├── 04_mapreduce_simulation.R # Runs the core MapReduce jobs
│ └── 05_sentiment_analysis.R # Performs advanced sentiment analysis
├── .gitignore # Specifies files for Git to ignore
├── full_dashboard.py # The main Python Dash application
├── README.md # This file
├── requirements.txt # Python dependencies
└── raw_tweets.csv # (Generated by R script)
└── *.csv # (Generated by R scripts)