Skip to content

Repository files navigation

India Predicts 2026 - Multi-State Election Predictor

An end-to-end machine learning pipeline forecasting Assembly election outcomes for 5 states:

  • Assam (126 seats)
  • Kerala (140 seats)
  • Puducherry (30 seats)
  • Tamil Nadu (234 seats)
  • West Bengal (294 seats)

Overview

This project simulates and predicts electoral outcomes by fusing historical results, parliamentary momentum, polling analysis, regional political issues, and neural network ensembles.

The pipeline includes scripts for detailed single-state analysis (like Kerala) as well as a unified multi-state predictor:

  1. predict_all_states.py: The main multi-state engine. It builds constituency-level datasets, trains PyTorch ensembles for each state, and outputs W/L/O predictions into a unified Submission Template.
  2. create_dataset.py & train.py: A detailed single-state heuristic engine and training pipeline (originally designed for Kerala).

Methodology Description

Our prediction methodology for the multi-state Assembly elections relies on a robust hybrid framework that synthesizes domain-specific heuristic modeling, historical election data, polling analysis, and deep learning ensembles. The approach is designed to accurately capture macro-level electoral swings while accounting for micro-level constituency dynamics across all five states.

1. Data Fusion and Constituency-Level Projections

The foundation of our predictions is a deterministic baseline projection generated for each constituency. We fuse multiple streams of data to estimate initial alliance vote shares:

  • Historical Baselines: We anchor our projections on the 2021 Assembly election results (weighted at 30%).
  • Recent Momentum: We incorporate the 2024 Lok Sabha election voting patterns (weighted at 30%) to capture recent shifts in the political climate.
  • Polling Analysis: We integrate a consensus of major 2026 exit polls (e.g., Matrize, Axis MyIndia, Chanakya) to set state-wide seat targets (weighted at 40%).
  • Regional and Demographic Adjustments: We apply state-specific heuristic shifts based on socio-political regions. For example, targeted vote-share adjustments are made for Muslim-majority areas and the Barak Valley in Assam, the Kongu belt and Chennai in Tamil Nadu, and the North Bengal and Kolkata regions in West Bengal.

To ensure our constituency-level projections match the macro-level exit poll consensus, we employ an iterative gradient calibration technique. This process incrementally adjusts alliance biases until the aggregated projected seat counts align with our state-wide targets. A reproducible hash adds marginal noise to allow for realistic edge-case seat flips.

2. Machine Learning Ensemble Models

To generalize these calibrated projections and identify the most robust winners, we train a custom neural network ensemble tailored to each state.

  • Feature Engineering: Input features include the calibrated alliance vote shares, the projected winning margins, and a deterministic 4-dimensional hash signature of the constituency name to capture localized idiosyncrasies.
  • Model Architecture: We utilize a PyTorch-based neural network featuring a projection layer followed by multiple Residual Blocks with Layer Normalization, GELU activations, and Dropout. The network uses a dual-head architecture: a classification head to predict the winning alliance (logits) and a regression head to predict continuous vote shares (softmax).
  • Training Strategy: Models are trained using a Repeated K-Fold cross-validation strategy (5 splits, 3 repeats) to build a stable ensemble. To mitigate class imbalance for smaller alliances, we utilize a WeightedRandomSampler and class-weighted Cross-Entropy loss. The optimizer minimizes a blended loss function consisting of classification accuracy (55%) and regression error (45%).

3. Alliance-to-Candidate Mapping

Once the ensemble predicts the winning alliance for every constituency, we map these victories to the individual candidate level. Using a predefined alliance-to-party hierarchy, the "Win" (W) outcome is deterministically assigned to the candidate belonging to the primary lead party of the winning alliance. All other competing candidates in the constituency are assigned a "Loss" (L).

(Note: Our codebase also implements an advanced multi-modal architecture with Transformer-based historical encoders and sentiment analysis components, designed for granular feature interaction. However, the primary state-wide predictions are driven by the robust heuristic-MLP ensemble detailed above.)

Usage

To run the unified multi-state predictor and populate the Submission Template.xlsx with 'W'/'L'/'O' labels:

python predict_all_states.py

This script will output updated prediction sheets directly into the Submission Template file and save internal CSV data to the data_files/ directory.

To run the detailed single-state Kerala pipeline:

python create_dataset.py
python train.py

About

No description, website, or topics provided.

Resources

Stars

8 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages