An AI-driven policy simulation platform that helps evaluate the potential economic, social, and sector-level effects of policy changes before implementation.
The application combines machine learning, natural language processing, economic modeling, and REST APIs to provide a structured view of possible policy outcomes.
Policy decisions can affect multiple areas of an economy at the same time. A change in fuel prices, taxes, subsidies, wages, or regulations may influence inflation, individual sectors, public sentiment, and overall economic risk.
Snowflake was developed to provide a simulation environment where users can define a policy scenario and examine its potential impact across multiple dimensions.
The platform supports both individual policy simulations and comparison of multiple scenarios.
Users can define a policy scenario by specifying:
- Policy type
- Percentage or magnitude of change
- Duration
- Affected sectors
- Optional policy description
The system processes these inputs and generates a consolidated impact assessment.
A machine learning model based on Gradient Boosting Regressor is used to estimate the potential effect of policy changes on inflation.
The model considers economic indicators such as:
- Fuel price changes
- Tax rate changes
- Subsidy changes
- Interest rates
- Money supply growth
The application uses a simplified Leontief input-output approach to estimate direct and indirect effects across different economic sectors.
The current model considers sectors including:
- Agriculture
- Manufacturing
- Services
- Transport
- Energy
- Healthcare
- Education
- Information Technology
TextBlob is used for basic NLP-based sentiment analysis.
The system processes policy-related reactions and provides an overview of:
- Positive sentiment
- Negative sentiment
- Neutral sentiment
- Overall sentiment score
A composite risk score is calculated using multiple factors:
- Economic risk
- Sector disruption
- Social unrest
- Income inequality
The resulting score is represented on a 0-100 scale to provide an overall view of potential policy risk.
Multiple policy scenarios can be evaluated and compared.
The comparison provides:
- Scenario ranking
- Risk scores
- Impact comparison
- Visualization
- Recommended option based on the calculated results
- Python
- FastAPI
- Pydantic
- scikit-learn
- pandas
- NumPy
- TextBlob
- HTML5
- CSS3
- JavaScript
- Chart.js
- Gradient Boosting Regressor
- Sentiment Analysis
- Economic indicator processing
- Sector interdependency modeling
- Risk scoring
The backend exposes REST APIs using FastAPI.
FastAPI also provides automatically generated OpenAPI documentation for the available endpoints.
The application follows a client-server architecture.
User
|
v
Frontend
HTML / CSS / JavaScript
|
| HTTP / JSON
v
FastAPI Backend
|
+-----------------------------+
| |
v v
Policy Simulation Data Processing
| |
+-------------+---------------+
|
+--------+--------+-------------+
| | |
v v v
Inflation Model Sector Analysis Sentiment
| | |
+-----------------+-------------+
|
v
Risk Assessment
|
v
Simulation Result
|
v
Frontend
snowflake/
|
├── backend/
│ ├── models/
│ │ └── Machine learning and analytical models
│ │
│ ├── services/
│ │ └── Simulation and business logic
│ │
│ ├── api/
│ │ └── API routes and request schemas
│ │
│ ├── data/
│ │ └── CSV and JSON datasets
│ │
│ ├── app.py
│ └── config.py
│
├── frontend/
│ ├── index.html
│ ├── css/
│ │ └── styles.css
│ ├── js/
│ │ └── JavaScript modules
│ └── assets/
│
├── tests/
│ └── Application tests
│
├── notebooks/
│ └── Experimentation and demonstrations
│
├── requirements.txt
└── README.md
The application follows a multi-stage processing workflow.
The user selects a policy type and defines its expected magnitude and duration.
For example:
Policy Type: Fuel Price Change
Magnitude: 15%
Duration: 12 months
Affected Sectors: Transport, Energy
The backend validates the input and prepares the required parameters for the individual analytical components.
The inflation model estimates the possible change in inflation based on the supplied policy parameters.
The sector model evaluates both direct effects and potential ripple effects across interconnected sectors.
Policy-related reactions are processed using TextBlob to estimate the overall public sentiment.
The individual impact measurements are combined to calculate an overall risk score.
The frontend presents the results through charts, scores, comparisons, and structured summaries.
The project uses a Gradient Boosting Regressor for inflation prediction.
Input features include:
fuel_price_change
tax_rate_change
subsidy_change
interest_rate
money_supply_growth
The model is trained using economic data covering multiple quarters.
A simplified Leontief input-output model is used to represent relationships between economic sectors.
The model considers:
Direct Impact
+
Indirect Impact
+
Sector Interdependencies
=
Overall Sector Impact
TextBlob is used to calculate sentiment polarity from policy-related text.
The result is summarized into positive, negative, and neutral sentiment categories.
The overall risk score combines multiple dimensions:
Economic Risk 35%
Sector Disruption 25%
Social Unrest 25%
Income Inequality 15%
The final score ranges from 0 to 100.
0 - 25 Low
26 - 50 Moderate
51 - 75 High
76 - 100 Critical
The application exposes REST endpoints through FastAPI.
GET /api/healthUsed to verify that the backend service and required models are available.
POST /api/simulateExample request:
{
"policy_type": "Fuel Price Change",
"magnitude": 15.0,
"duration_months": 12,
"affected_sectors": [
"Transport",
"Energy"
],
"description": "15% fuel price increase over 12 months"
}The endpoint returns the calculated inflation impact, sector analysis, sentiment analysis, risk assessment, and recommendations.
POST /api/compareUsed to compare multiple policy scenarios.
Example:
{
"scenarios": [
{
"name": "Option A",
"policy_type": "Tax Reform",
"magnitude": 10,
"duration_months": 12
},
{
"name": "Option B",
"policy_type": "Subsidy Change",
"magnitude": -15,
"duration_months": 6
}
]
}GET /api/sectorsReturns the available economic sectors and their associated relationships.
GET /api/policy-typesReturns the policy categories supported by the simulator.
GET /api/history?limit=10Returns recently processed simulation results.
Make sure the following are installed:
- Python 3.9 or later
- pip
- Modern web browser
git clone https://github.com/NehaAnthony/snowflake.git
cd snowflakepip install -r requirements.txtIf required by the TextBlob configuration, install the required NLTK resources:
python -c "import nltk; nltk.download('brown'); nltk.download('punkt'); nltk.download('wordnet'); nltk.download('omw-1.4')"python backend/app.pyThe application will be available at:
http://localhost:8000
FastAPI API documentation:
http://localhost:8000/api/docs
Unit tests can be executed using:
pytest tests/ -vThe testing structure covers important components such as:
- Inflation prediction
- Sector impact calculations
- Sentiment analysis
- Risk calculation
Consider a scenario where fuel prices increase by 20%.
The system can evaluate:
Inflation Impact
|
v
Sector Impact
|
v
Public Sentiment
|
v
Economic Risk
|
v
Overall Assessment
The output can then be used to compare the scenario against alternative policy options.
This project provided practical experience in several areas of software development and applied AI:
- Designing and consuming REST APIs
- Building backend services using FastAPI
- Applying machine learning to structured data
- Working with pandas and NumPy for data processing
- Implementing NLP-based sentiment analysis
- Creating a multi-factor risk scoring system
- Modeling relationships between economic sectors
- Building interactive frontend visualizations
- Structuring a project into separate frontend and backend layers
- Writing and organizing application tests
Potential improvements include:
- Integration with real-time economic datasets
- More advanced forecasting models
- Improved sentiment analysis using transformer-based NLP models
- User authentication and role-based access
- Persistent database support
- Historical simulation dashboards
- More detailed policy recommendation models
- Cloud deployment
- Automated CI/CD pipeline
- Improved test coverage
M.Tech (Artificial Intelligence and Data Science)
Neha Anthony is a developer with experience in Java development, backend API development, cloud technologies, and application development.
Technical areas of interest include:
- Java
- Python
- Spring Boot
- FastAPI
- REST API Development
- Machine Learning
- AWS
- Data Processing
- Full-Stack Development
For questions, suggestions, or collaboration, please use the GitHub repository's Issues section.
This project was developed as a practical implementation of machine learning, backend API development, data processing, and interactive visualization.