Skip to content

Latest commit

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Snowflake - AI Policy Impact Simulator

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.

Project Overview

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.

Key Features

Policy Simulation

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.

Inflation Prediction

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

Sector Impact Analysis

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

Public Sentiment Analysis

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

Risk Assessment

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.

Scenario Comparison

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

Technology Stack

Backend

  • Python
  • FastAPI
  • Pydantic
  • scikit-learn
  • pandas
  • NumPy
  • TextBlob

Frontend

  • HTML5
  • CSS3
  • JavaScript
  • Chart.js

Machine Learning and Data Processing

  • Gradient Boosting Regressor
  • Sentiment Analysis
  • Economic indicator processing
  • Sector interdependency modeling
  • Risk scoring

API

The backend exposes REST APIs using FastAPI.

FastAPI also provides automatically generated OpenAPI documentation for the available endpoints.

Application Architecture

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

Project Structure

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

How It Works

The application follows a multi-stage processing workflow.

1. Policy Input

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

2. Data Processing

The backend validates the input and prepares the required parameters for the individual analytical components.

3. Economic Impact Prediction

The inflation model estimates the possible change in inflation based on the supplied policy parameters.

4. Sector Analysis

The sector model evaluates both direct effects and potential ripple effects across interconnected sectors.

5. Sentiment Analysis

Policy-related reactions are processed using TextBlob to estimate the overall public sentiment.

6. Risk Calculation

The individual impact measurements are combined to calculate an overall risk score.

7. Result Visualization

The frontend presents the results through charts, scores, comparisons, and structured summaries.

Machine Learning Models

Inflation Prediction

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.

Sector Impact Model

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

Sentiment Analysis

TextBlob is used to calculate sentiment polarity from policy-related text.

The result is summarized into positive, negative, and neutral sentiment categories.

Risk Index

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

API Documentation

The application exposes REST endpoints through FastAPI.

Health Check

GET /api/health

Used to verify that the backend service and required models are available.

Simulate Policy

POST /api/simulate

Example 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.

Compare Scenarios

POST /api/compare

Used 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
}
]
}

Available Sectors

GET /api/sectors

Returns the available economic sectors and their associated relationships.

Available Policy Types

GET /api/policy-types

Returns the policy categories supported by the simulator.

Simulation History

GET /api/history?limit=10

Returns recently processed simulation results.

Installation and Setup

Prerequisites

Make sure the following are installed:

  • Python 3.9 or later
  • pip
  • Modern web browser

Clone the Repository

git clone https://github.com/NehaAnthony/snowflake.git
cd snowflake

Install Dependencies

pip install -r requirements.txt

Install Required NLP Data

If 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')"

Run the Application

python backend/app.py

The application will be available at:

http://localhost:8000

FastAPI API documentation:

http://localhost:8000/api/docs

Testing

Unit tests can be executed using:

pytest tests/ -v

The testing structure covers important components such as:

  • Inflation prediction
  • Sector impact calculations
  • Sentiment analysis
  • Risk calculation

Example Simulation

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.

Development Highlights

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

Future Improvements

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

Author

Neha Anthony

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

Contact

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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages