nigeria-carbon-emissions-dataset / verify_carbon_dataset.py
mabera's picture
Upload 10 files
ae1ef57 verified
Raw
History Blame Contribute Delete
4.45 kB
"""
Nigeria Carbon Emissions & Economic Trajectory Interpreter — Verification
AutoScientist Challenge 2026, Part 2 — Market Analysis & News Category
Author: Hussein Adeiza (mabera)
Independently re-derives every numeric claim in the training dataset
directly from the raw, unmodified source file downloaded from
Our World in Data's GitHub repository (owid/co2-data).
Usage:
python verify_carbon_dataset.py
(requires owid_co2_full.csv, the raw downloaded source file,
in the same directory)
"""
import pandas as pd
import sys
def verify_all_claims(raw_source_path, dataset_path):
raw = pd.read_csv(raw_source_path)
dataset = pd.read_csv(dataset_path)
print("=" * 70)
print("VERIFICATION: Re-deriving every numeric claim from the RAW source file")
print("Source: Our World in Data, owid/co2-data, downloaded from GitHub")
print("=" * 70)
all_pass = True
nigeria = raw[raw['country'] == 'Nigeria']
comp2022 = raw[raw['year'] == 2022]
# Claim 1: total vs per-capita divergence, 2000-2024
co2_2000 = nigeria[nigeria['year']==2000]['co2'].values[0]
co2_2024 = nigeria[nigeria['year']==2024]['co2'].values[0]
pc_2000 = nigeria[nigeria['year']==2000]['co2_per_capita'].values[0]
pc_2024 = nigeria[nigeria['year']==2024]['co2_per_capita'].values[0]
total_change = round((co2_2024/co2_2000 - 1) * 100, 1)
pc_change = round(abs((pc_2024/pc_2000 - 1) * 100), 1)
check1 = str(total_change) in dataset.iloc[0]['completion'] and str(pc_change) in dataset.iloc[0]['completion']
print(f"Claim 1 (2000->2024 total vs per-capita): total +{total_change}%, "
f"per-capita -{pc_change}% — {'PASS' if check1 else 'FAIL'}")
if not check1:
all_pass = False
# Claim 2: Nigeria vs South Africa per-capita ratio
nigeria_pc = comp2022[comp2022['country']=='Nigeria']['co2_per_capita'].values[0]
sa_pc = comp2022[comp2022['country']=='South Africa']['co2_per_capita'].values[0]
ratio = round(sa_pc / nigeria_pc, 1)
check2 = str(ratio) in dataset.iloc[1]['completion']
print(f"Claim 2 (SA vs Nigeria per-capita ratio): {ratio}x — {'PASS' if check2 else 'FAIL'}")
if not check2:
all_pass = False
# Claim 3: Carbon intensity ratios
nigeria_intensity = comp2022[comp2022['country']=='Nigeria']['co2_per_gdp'].values[0]
sa_intensity = comp2022[comp2022['country']=='South Africa']['co2_per_gdp'].values[0]
world_intensity = comp2022[comp2022['country']=='World']['co2_per_gdp'].values[0]
sa_ratio = round(sa_intensity/nigeria_intensity, 1)
world_ratio = round(world_intensity/nigeria_intensity, 1)
check3 = str(sa_ratio) in dataset.iloc[2]['completion'] and str(world_ratio) in dataset.iloc[2]['completion']
print(f"Claim 3 (carbon intensity ratios): SA {sa_ratio}x, World {world_ratio}x — {'PASS' if check3 else 'FAIL'}")
if not check3:
all_pass = False
# Claim 4: trade CO2 values
nigeria_trade = comp2022[comp2022['country']=='Nigeria']['trade_co2'].values[0]
sa_trade = comp2022[comp2022['country']=='South Africa']['trade_co2'].values[0]
check4 = str(nigeria_trade) in dataset.iloc[3]['completion'] and str(sa_trade) in dataset.iloc[3]['completion']
print(f"Claim 4 (trade CO2): Nigeria {nigeria_trade}, SA {sa_trade}{'PASS' if check4 else 'FAIL'}")
if not check4:
all_pass = False
# Claim 5: oil vs gas growth rates
oil_2000 = nigeria[nigeria['year']==2000]['oil_co2'].values[0]
oil_2024 = nigeria[nigeria['year']==2024]['oil_co2'].values[0]
gas_2000 = nigeria[nigeria['year']==2000]['gas_co2'].values[0]
gas_2024 = nigeria[nigeria['year']==2024]['gas_co2'].values[0]
oil_growth = round((oil_2024/oil_2000 - 1) * 100, 1)
gas_growth = round((gas_2024/gas_2000 - 1) * 100, 1)
check5 = str(oil_growth) in dataset.iloc[4]['completion'] and str(gas_growth) in dataset.iloc[4]['completion']
print(f"Claim 5 (oil vs gas growth): oil +{oil_growth}%, gas +{gas_growth}% — {'PASS' if check5 else 'FAIL'}")
if not check5:
all_pass = False
print()
print("=" * 70)
print(f"FINAL RESULT: {'ALL 5 CLAIMS VERIFIED against the raw source file' if all_pass else 'FAILURES DETECTED'}")
print("=" * 70)
return all_pass
if __name__ == "__main__":
ok = verify_all_claims("owid_co2_full.csv", "final/nigeria_carbon_interpreter_dataset.csv")
if not ok:
sys.exit(1)