Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nepal Election 2082 - Data Analysis

In this project, I analyzed a synthetic dataset of Nepal's hypothetical 2082 BS general election spanning 55 constituencies, 26 political parties, 215 candidates, and over 3,000 registered voters. Starting from 9 raw CSV files — covering everything from candidate profiles and voter demographics to campaign rallies, social media hashtags, media news coverage, and political scandals — I explored how these factors interrelate and ultimately shape election outcomes.

What I did:

  • Loaded and cleaned all 9 datasets (parties, candidates, voters, votes, results, campaign events, social media trends, media news coverage, and political scandals), handling missing party IDs for independent candidates and Bikram Sambat calendar dates.
  • Investigated candidate demographics (age, gender, education, criminal records, declared assets, campaign budgets) and voter turnout patterns across provinces, gender, and age groups.
  • Analyzed campaign activity — rally attendance and media coverage scores — and their correlation with actual vote share.
  • Measured social media sentiment (hashtag mentions and sentiment scores on TikTok, YouTube, Facebook, Twitter) and ran linear regressions against vote percentage.
  • Examined media news coverage sentiment (positive, negative, neutral) per party and computed net sentiment ratios to assess media favorability.
  • Assessed the impact of political scandals (corruption, financial misconduct, policy controversies) on candidates' vote share and win rates using statistical tests.
  • Built a Random Forest model combining all these features to predict each candidate's vote percentage, and extracted feature importances to understand what matters most.

The outcome:

  • Nepali Congress (NC) won the most seats — 20 out of 55 (36.4%) — led by Sher Bahadur Deuba, but fell short of the 28-seat majority threshold, resulting in a hung parliament.
  • Scandals, media sentiment, social media buzz, and campaign spending all showed measurable associations with candidate performance, which the multi-factor model captures.

Disclaimer: All data in this project is entirely fictional and synthetically generated. It was created solely for educational and learning purposes. None of the data represents real election outcomes, real individuals, real political parties, or actual events. Any resemblance to real persons or organizations is purely coincidental and unintentional. Do not cite this data as factual or use it for any real-world decision-making.

Sample Results

Parliament Composition

Parliament composition

Winner Vote Percentage by Constituency

Winner vote percentage

Feature Importance (Random Forest Model)

Feature importance

Prediction: Actual vs Predicted Vote %

Prediction scatter

Project Structure

Election-2082/
├── data/                          # All CSV datasets
│   ├── political_parties_2082.csv
│   ├── candidates_2082.csv
│   ├── voters_2082.csv
│   ├── votes_2082.csv
│   ├── election_results_2082.csv
│   ├── campaign_events.csv
│   ├── social_media_trends.csv
│   ├── media_news_coverage.csv
│   └── political_scandals.csv
├── Analysis/
│   └── nepal_election_2082_analysis.ipynb   # Main analysis notebook
├── scripts/
│   ├── export_images.py                    # Generate charts from CSVs
│   └── compute_winner.py                   # Compute election winner
├── images/                        # Generated charts and predictions
├── .venv/                         # Python virtual environment
└── Readme.md

Dataset Overview

Table Rows Columns Description
political_parties_2082.csv 26 9 Party info: name, leader, ideology, members, symbol
candidates_2082.csv 215 12 Candidate profiles: age, gender, education, assets, budget
voters_2082.csv 3,001 11 Registered voters: demographics, location, voted flag
votes_2082.csv 2,010 5 Individual vote records linking voters to candidates
election_results_2082.csv 215 7 Aggregated results: vote count, percentage, rank per constituency
campaign_events.csv 351 7 Campaign rallies, speeches, etc. with attendance and media scores
social_media_trends.csv 251 7 Hashtag trends across platforms with sentiment scores
media_news_coverage.csv 301 7 News articles with sentiment and impact scores
political_scandals.csv 81 6 Scandal records with media attention and public reaction

Entity Relationships

political_parties  <──(party_id)──  candidates  <──(candidate_id)──  election_results
                                        │
                                   (candidate_id)
                                        │
                       ┌────────────────┼────────────────┐
                       ▼                ▼                ▼
                 campaign_events  social_media_trends  political_scandals
                                        │
                                        ▼
                               media_news_coverage

voters  ──(voter_id)──>  votes  <──(candidate_id)──  candidates
  • party_id links parties to candidates and results
  • candidate_id links candidates to votes, events, social media, news, and scandals
  • voter_id links voters to their vote records
  • constituency_id is shared across candidates, voters, votes, and results

Analysis Sections

The notebook covers 20 analysis sections:

  1. Data Loading — Load all 9 CSV tables, verify row counts
  2. Data Inspection — Schema validation, dtypes, null checks
  3. Data Cleaning — Type casting, BS date handling, categorical encoding
  4. Join Integrity — Referential integrity checks across all tables
  5. Party Overview — Ideology distribution, membership, establishment timeline
  6. Candidate Demographics — Age, gender, education, profession, criminal status, budget
  7. Voter Demographics — Age, gender, province, urban/rural, education, occupation
  8. Voter Turnout — Overall and breakdown by province, gender, age, education
  9. Constituency Winners — Winner table, vote percentage chart, landslide detection
  10. Parliament Composition — Seat distribution, donut chart, proportionality analysis
  11. Constituency Competitiveness — Candidate counts, budget advantage proxy analysis
  12. Gender Representation — Win rates by gender, Mann-Whitney U test
  13. Campaign Activity — Events, attendance, media score vs vote correlation
  14. Social Media Sentiment — Sentiment and mentions vs vote share, linear regression
  15. Media News Coverage — Sentiment breakdown per party, net sentiment ratio
  16. Scandal Impact — Vote share and win rate comparison, statistical testing
  17. Controversial Candidates — Composite controversy score, bubble chart
  18. Wealth vs Outcome — Assets and budget vs win probability, logistic regression
  19. Timeline Analysis — Campaign events, social media, news over time
  20. Multi-Factor Model — Random Forest predicting vote percentage, feature importance

Tech Stack

  • Python 3.14
  • pandas — data manipulation
  • numpy — numerical operations
  • matplotlib / seaborn — visualization
  • scipy — statistical tests (Mann-Whitney U, Pearson, Spearman)
  • scikit-learn — Linear Regression, Logistic Regression, Random Forest, cross-validation

Getting Started

# clone the repo
git clone <repo-url>
cd Election-2082

# create virtual environment
python -m venv .venv
.venv\Scripts\activate      # Windows
# source .venv/bin/activate  # Linux/Mac

# install dependencies
pip install pandas numpy matplotlib seaborn scipy scikit-learn

# open the notebook
jupyter notebook Analysis/nepal_election_2082_analysis.ipynb

Known Data Quirks

  • Equal vote counts: In this synthetic dataset, every candidate in a constituency receives vote_count = 100 and vote_percentage = 100/N (where N = number of candidates). Traditional margin-of-victory analysis returns zero everywhere. The notebook uses alternative competitiveness proxies instead.
  • BS calendar dates: Dates like 2082-04-15 are Bikram Sambat and cannot be parsed by pd.to_datetime(). They are kept as strings and sorted lexicographically.
  • 15 independent candidates have party_id = NaN, handled with fillna in the analysis.

License

This project and its synthetic data are provided for educational purposes only.

Reminder: This is NOT real data. Everything — parties, candidates, voters, votes, results, scandals — is synthetically generated for learning. Do not treat any of it as factual.

Regenerating Images

To regenerate the charts from the CSVs (non-interactive):

.venv\Scripts\activate   # Windows
python scripts/export_images.py

This creates the following in images/:

File Description
parliament.png Seat distribution bar + donut chart
winner_vote_pct.png Winner vote % by constituency
feature_importance.png Random Forest feature importance
prediction_scatter.png Actual vs predicted vote % scatter
predictions.csv Per-candidate actual & predicted vote %

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages