Skip to content

27Aditi/BharatLens

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

BharatLens โ€” India's AI-Powered Economic Intelligence Platform

Real-time economic analysis, LSTM forecasting, multilingual news sentiment, and macro simulation โ€” all in one dashboard.

Python Streamlit PyTorch License


Problem Statement

India's economic data is fragmented across dozens of sources โ€” stock indices on one platform, inflation data on another, state-level indicators buried in government PDFs, and news scattered across hundreds of portals. Existing platforms like Bloomberg or Moneycontrol display numbers but offer no explanation, no prediction, and no simulation.

BharatLens solves this by aggregating real-time data from multiple sources, applying AI to analyze and forecast it, and presenting everything in a single interactive dashboard โ€” in both Hindi and English.


Features

Module Description
Market Pulse Live NIFTY, SENSEX, Gold, Crude Oil, USD/INR with % change
NIFTY Forecast LSTM neural network trained on 3 years of data with uncertainty bands
News Sentiment FinBERT-powered sentiment analysis on Hindi and English financial news
State Health Economic health score for 15 Indian states
What-If Lab Simulate impact of RBI rate changes, crude oil prices, FDI, and currency shifts

Architecture

BharatLens/
โ”‚
โ”œโ”€โ”€ app.py                  # Main Streamlit dashboard
โ”‚
โ”œโ”€โ”€ modules/
โ”‚   โ”œโ”€โ”€ data_fetch.py       # Data ingestion (Yahoo Finance, World Bank, RSS)
โ”‚   โ”œโ”€โ”€ sentiment.py        # FinBERT sentiment analysis (Hindi + English)
โ”‚   โ””โ”€โ”€ whatif.py           # What-If econometric simulator
โ”‚
โ”œโ”€โ”€ models/
โ”‚   โ””โ”€โ”€ lstm_model.py       # LSTM architecture, training, forecasting
โ”‚
โ””โ”€โ”€ requirements.txt

Pipeline Flow

Data Sources           Processing                Output
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€           โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                โ”€โ”€โ”€โ”€โ”€โ”€
Yahoo Finance    โ†’     MinMax Scaling      โ†’     LSTM Forecast
World Bank API   โ†’     Feature Engineering โ†’     Macro Dashboard
RSS News Feeds   โ†’     Hindi Translation   โ†’     Sentiment Score
                       FinBERT Inference   โ†’     Market Mood
Static State Data โ†’    Weighted Scoring    โ†’     State Health Map
User Sliders      โ†’    Econometric Model   โ†’     Sector Impact

AI/ML Components

1. LSTM Forecasting Model

  • Architecture: 2-layer LSTM โ†’ Linear(64 โ†’ 32) โ†’ Linear(32 โ†’ 1)
  • Input: Last 60 trading days of NIFTY 50 closing prices
  • Preprocessing: MinMaxScaler normalization to [0, 1]
  • Split: 85% training / 15% validation
  • Loss Function: Mean Squared Error (MSE)
  • Output: Next N days forecast with ยฑ1.5% uncertainty bands
  • Why LSTM: Stock prices are sequential โ€” LSTM's memory cell captures long-term dependencies that standard feedforward networks miss

2. Sentiment Analysis โ€” FinBERT

  • Model: ProsusAI/finbert โ€” BERT fine-tuned on financial text
  • Labels: Positive / Negative / Neutral
  • Hindi Support: Devanagari text is auto-detected, translated to English via GoogleTranslator, then passed to FinBERT
  • Why FinBERT over BERT: Domain-specific training on financial corpora makes it understand terms like "rate hike", "market rally", and "FII outflow" accurately

3. What-If Simulator

Elasticity coefficients derived from historical Indian market behavior:

  • RBI rate hike of 25 bps โ†’ NIFTY approximately -1.2%
  • Crude oil +$5/barrel โ†’ NIFTY approximately -0.4%
  • INR depreciation of Rs 1 โ†’ IT sector +0.8%, NIFTY -0.3%
  • FDI inflow of +$1B โ†’ NIFTY approximately +0.6%

Getting Started

Prerequisites

  • Python 3.8 or above
  • Active internet connection for live data fetching

Installation

# Clone the repository
cd BharatLens

# Create a virtual environment (recommended)
python -m venv deepv
deepv\Scripts\activate        # Windows
source deepv/bin/activate     # Mac/Linux

# Install dependencies
pip install -r requirements.txt

# Run the app
streamlit run app.py

The app will open at http://localhost:8501

Note: FinBERT model (~500MB) downloads automatically on first use of the News Sentiment tab. This is a one-time download.


Tech Stack

Layer Technology
Dashboard Streamlit
Neural Network PyTorch
NLP Model HuggingFace Transformers (FinBERT)
Market Data yfinance โ€” Yahoo Finance
Macro Data World Bank Open API
News feedparser โ€” ET, MoneyControl, NDTV Profit RSS
Translation deep-translator โ€” Google Translate
Visualization Plotly
Data Processing Pandas, NumPy, Scikit-learn

Data Sources

Source Data Provided
Yahoo Finance NIFTY 50, SENSEX, NIFTY Bank, NIFTY IT, USD/INR, Gold, Crude Oil
World Bank API GDP Growth, Inflation (CPI), Unemployment, FDI Inflows
Economic Times RSS Financial news headlines
MoneyControl RSS Economy news
NDTV Profit RSS Market updates

Key Design Decisions

Why LSTM over simple regression? Economic time series have long-range temporal dependencies. Linear regression predicting tomorrow's NIFTY from today's price misses patterns like weekly cycles, quarterly earnings effects, and macro shock aftereffects. LSTM's gated memory architecture is designed specifically for this.

Why FinBERT over standard BERT? General-purpose BERT was trained on Wikipedia and BookCorpus โ€” it does not understand financial jargon. FinBERT was fine-tuned on financial news and earnings call transcripts, making it significantly more accurate on domain-specific terms.

Why translate Hindi instead of using a multilingual model? Multilingual models like mBERT perform poorly on financial Hindi and Hinglish text because labeled training data for this domain in Hindi is scarce. Translating to English first and using the domain-expert FinBERT gives more reliable results.


Future Improvements

  • Add FII/DII flow data from NSE
  • Integrate RBI monetary policy calendar
  • Add portfolio risk calculator
  • Add alert system for high-risk economic signals
  • Expand state coverage to all 28 states and 8 Union Territories

License

MIT License โ€” free to use, modify, and distribute.

About

๐Ÿ‡ฎ๐Ÿ‡ณ AI-powered dashboard to track India's economic pulse โ€” LSTM forecasting, FinBERT sentiment analysis on Hindi & English news, state-level economic health scores, and a What-If macro simulator. Built with Streamlit, PyTorch & HuggingFace.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages