|
|
import pandas as pd |
|
|
import numpy as np |
|
|
from xgboost import XGBRegressor |
|
|
import gradio as gr |
|
|
|
|
|
|
|
|
|
|
|
df = pd.read_csv("Nigeria Economy Dataset_1990-2022.csv") |
|
|
|
|
|
|
|
|
|
|
|
features = ['Agriculture to GDP', 'Industry to GDP', 'Services to GDP', 'Inflation rate', 'Government debt'] |
|
|
target = 'Real GDP' |
|
|
|
|
|
|
|
|
X = df[features] |
|
|
y = df[target] |
|
|
model = XGBRegressor() |
|
|
model.fit(X, y) |
|
|
|
|
|
|
|
|
def simulate_gdp(agri, indus, service, inflation, debt): |
|
|
input_df = pd.DataFrame([[agri, indus, service, inflation, debt]], columns=features) |
|
|
prediction = model.predict(input_df)[0] |
|
|
return f"π° Estimated GDP: ${prediction:,.2f} Billion USD" |
|
|
|
|
|
|
|
|
iface = gr.Interface( |
|
|
fn=simulate_gdp, |
|
|
inputs=[ |
|
|
gr.Slider(0, 100, value=20, label="Agriculture Contribution (%)"), |
|
|
gr.Slider(0, 100, value=25, label="Industry Contribution (%)"), |
|
|
gr.Slider(0, 100, value=50, label="Services Contribution (%)"), |
|
|
gr.Slider(0, 50, value=10, label="Inflation Rate (%)"), |
|
|
gr.Slider(0, 200, value=50, label="Government Debt (Billion USD)") |
|
|
], |
|
|
outputs="text", |
|
|
title="π³π¬ Nigeria GDP Forecasting & Policy Simulator", |
|
|
description=""" |
|
|
This tool uses AI to predict Nigeria's GDP based on key economic inputs. |
|
|
Adjust the sliders to simulate policy scenarios and their likely economic outcomes. |
|
|
Powered by XGBoost and real historical data (1990β2022). |
|
|
""" |
|
|
) |
|
|
|
|
|
|
|
|
iface.launch() |
|
|
|