import gradio as gr # Nigeria Health & Poverty AI Demo v10 # AutoScientist Challenge 2026 | Healthcare, Finance, Language, Legal & Marketing Categories # Author: Hussein Adeiza (mabera) — Licensed Environmental Health Officer, Abuja Nigeria # ── WASH Model ───────────────────────────────────────────── def predict_wash_risk(improved_water, improved_sanitation, open_defecation, handwashing): risk_score = ( (100 - improved_water) * 0.005 + (100 - improved_sanitation) * 0.205 + open_defecation * 0.134 + (100 - handwashing) * 0.002 ) risk_score = min(max(risk_score, 5), 35) if risk_score > 20: risk_level = "🔴 HIGH RISK" recommendation = "Urgent intervention needed in sanitation infrastructure and open defecation elimination." elif risk_score > 13: risk_level = "🟡 MODERATE RISK" recommendation = "Focus on improving sanitation facilities and expanding handwashing access." else: risk_level = "🟢 LOW RISK" recommendation = "Maintain current WASH coverage and continue expanding access." return f""" ## WASH Risk Assessment — Nigeria **Predicted Child Diarrhea Risk: {risk_score:.1f}%** **Risk Level: {risk_level}** ### Input Summary - Improved Water Access: {improved_water}% - Improved Sanitation: {improved_sanitation}% - Open Defecation: {open_defecation}% - Handwashing Facility: {handwashing}% ### Key Finding Unimproved sanitation is the **#1 driver** of child diarrhea in Nigeria. ### Recommendation {recommendation} ### Historical Context (Nigeria DHS 2003–2024) | Year | Improved Water | Improved Sanitation | Child Diarrhea | |------|---------------|--------------------|----| | 2003 | 49.3% | 17.9% | 22.9% | | 2018 | 75.4% | 55.5% | 16.3% | | 2024 | 78.3% | 66.6% | 18.3% | ### ⚠️ Honest Calibration Note A supplementary check against all 5 real DHS reporting years (2003-2024) found this simplified demo formula only achieves **40% pairwise rank agreement** with actual recorded diarrhea prevalence, worse than chance. Shared transparently rather than only highlighting the strong official result. --- *Nigeria WASH Risk Model — Fine-tuned Llama 3.3 70B | AutoScientist 2026* """ # ── Malaria Model ─────────────────────────────────────────── def predict_malaria_risk(children_itn, pregnant_itn, hh_itn, immunization): risk_score = (100 - (pregnant_itn * 1.536) + (children_itn * 0.345) - (immunization * 0.1)) / 10 risk_score = min(max(risk_score, 20), 60) if risk_score > 45: risk_level = "🔴 HIGH RISK" recommendation = "Urgent scale-up of ITN distribution needed, especially for pregnant women." elif risk_score > 35: risk_level = "🟡 MODERATE RISK" recommendation = "Maintain ITN coverage gains and focus on pregnant women protection." else: risk_level = "🟢 LOW RISK" recommendation = "Sustain current ITN coverage and strengthen immunization programs." return f""" ## Malaria Risk Assessment — Nigeria **Predicted Malaria Prevalence: {risk_score:.1f}%** **Risk Level: {risk_level}** ### Input Summary - Children under ITN: {children_itn}% - Pregnant Women under ITN: {pregnant_itn}% - Households with ITN: {hh_itn}% - Immunization Coverage: {immunization}% ### Key Finding ⚠️ Malaria rose from 36.2% (2018) → 39.6% (2021) despite increased ITN coverage. ### Recommendation {recommendation} ### Historical Context (Nigeria DHS 2010–2021) | Year | Children ITN | Pregnant ITN | Malaria | |------|-------------|-------------|---------| | 2010 | 28.9% | 33.6% | 51.5% | | 2018 | 52.2% | 58.0% | 36.2% | | 2021 | 41.2% | 49.6% | 39.6% | --- *Nigeria Malaria Health Model — Fine-tuned Llama 3.3 70B | AutoScientist 2026* """ # ── Poverty Model ─────────────────────────────────────────── STATE_POVERTY = { "FCT": {"headcount": 10.2, "severe": 2.0, "mpi": 0.0414, "region": "North"}, "Abia": {"headcount": 9.4, "severe": 3.4, "mpi": 0.0419, "region": "South"}, "Adamawa": {"headcount": 39.1, "severe": 15.2, "mpi": 0.1820, "region": "North"}, "Akwa Ibom": {"headcount": 9.8, "severe": 3.6, "mpi": 0.0446, "region": "South"}, "Anambra": {"headcount": 2.0, "severe": 0.5, "mpi": 0.0089, "region": "South"}, "Bauchi": {"headcount": 75.4, "severe": 50.8, "mpi": 0.4411, "region": "North"}, "Bayelsa": {"headcount": 14.0, "severe": 6.0, "mpi": 0.0644, "region": "South"}, "Benue": {"headcount": 27.0, "severe": 7.7, "mpi": 0.1156, "region": "North"}, "Borno": {"headcount": 53.9, "severe": 31.1, "mpi": 0.2922, "region": "North"}, "Cross River": {"headcount": 19.1, "severe": 3.9, "mpi": 0.0775, "region": "South"}, "Delta": {"headcount": 11.8, "severe": 3.1, "mpi": 0.0507, "region": "South"}, "Ebonyi": {"headcount": 8.0, "severe": 1.1, "mpi": 0.0341, "region": "South"}, "Edo": {"headcount": 8.3, "severe": 1.7, "mpi": 0.0358, "region": "South"}, "Ekiti": {"headcount": 12.5, "severe": 3.5, "mpi": 0.0532, "region": "South"}, "Enugu": {"headcount": 6.9, "severe": 2.4, "mpi": 0.0300, "region": "South"}, "Gombe": {"headcount": 61.3, "severe": 40.2, "mpi": 0.3345, "region": "North"}, "Imo": {"headcount": 4.6, "severe": 0.3, "mpi": 0.0183, "region": "South"}, "Jigawa": {"headcount": 74.8, "severe": 52.0, "mpi": 0.4377, "region": "North"}, "Kaduna": {"headcount": 34.1, "severe": 14.7, "mpi": 0.1671, "region": "North"}, "Kano": {"headcount": 45.1, "severe": 26.7, "mpi": 0.2497, "region": "North"}, "Katsina": {"headcount": 61.1, "severe": 35.2, "mpi": 0.3331, "region": "North"}, "Kebbi": {"headcount": 73.8, "severe": 52.7, "mpi": 0.4373, "region": "North"}, "Kogi": {"headcount": 14.0, "severe": 5.7, "mpi": 0.0638, "region": "North"}, "Kwara": {"headcount": 20.2, "severe": 8.1, "mpi": 0.0962, "region": "North"}, "Lagos": {"headcount": 1.1, "severe": 0.2, "mpi": 0.0044, "region": "South"}, "Nasarawa": {"headcount": 40.6, "severe": 15.7, "mpi": 0.1888, "region": "North"}, "Niger": {"headcount": 44.6, "severe": 22.8, "mpi": 0.2191, "region": "North"}, "Ogun": {"headcount": 19.9, "severe": 6.9, "mpi": 0.0918, "region": "South"}, "Ondo": {"headcount": 14.4, "severe": 4.2, "mpi": 0.0637, "region": "South"}, "Osun": {"headcount": 7.5, "severe": 1.6, "mpi": 0.0315, "region": "South"}, "Oyo": {"headcount": 17.4, "severe": 6.3, "mpi": 0.0809, "region": "South"}, "Plateau": {"headcount": 42.5, "severe": 16.3, "mpi": 0.1945, "region": "North"}, "Rivers": {"headcount": 8.4, "severe": 1.4, "mpi": 0.0351, "region": "South"}, "Sokoto": {"headcount": 70.7, "severe": 51.4, "mpi": 0.4372, "region": "North"}, "Taraba": {"headcount": 56.7, "severe": 25.4, "mpi": 0.2702, "region": "North"}, "Yobe": {"headcount": 63.0, "severe": 43.6, "mpi": 0.3428, "region": "North"}, "Zamfara": {"headcount": 71.9, "severe": 44.7, "mpi": 0.3913, "region": "North"}, } def predict_poverty(state, severe_poverty, vulnerable, intensity): if state and state in STATE_POVERTY: data = STATE_POVERTY[state] headcount = data["headcount"] severe = data["severe"] mpi = data["mpi"] region = data["region"] else: is_north = 1 if state in [s for s, d in STATE_POVERTY.items() if d["region"] == "North"] else 0 headcount = intensity * (-0.501) + vulnerable * 0.348 + severe_poverty * 1.407 + is_north * 6.410 headcount = min(max(headcount, 0), 100) severe = severe_poverty mpi = headcount / 100 * 0.5 region = "North" if is_north else "South" if headcount > 50: risk_level = "🔴 EXTREME POVERTY" recommendation = "Urgent targeted intervention needed — social protection, economic empowerment, basic services." elif headcount > 25: risk_level = "🟠 HIGH POVERTY" recommendation = "Significant investment in education, healthcare and infrastructure required." elif headcount > 10: risk_level = "🟡 MODERATE POVERTY" recommendation = "Focus on financial inclusion, vocational training and social safety nets." else: risk_level = "🟢 LOW POVERTY" recommendation = "Maintain development gains and focus on inclusive growth policies." return f""" ## Poverty Assessment — {state if state else "Custom Input"} **Poverty Headcount Ratio: {headcount:.1f}%** **MPI Score: {mpi:.4f}** **Risk Level: {risk_level}** **Region: {region}** ### Recommendation {recommendation} ### Nigeria North-South Poverty Gap | Region | Avg Headcount | |--------|--------------| | North | 49.0% | | South | 10.3% | | **Gap** | **38.7pp** | --- *Nigeria Poverty Prediction Model — Fine-tuned Mixtral 8x7B | AutoScientist 2026* """ # ── Multilingual Health Assistant ─────────────────────────── HEALTH_QA = { "what is the main cause of diarrhea in nigeria": { "en": "The main cause of diarrhea in Nigerian children is unimproved sanitation. Poor sanitation — including open defecation — is the strongest predictor, stronger than water source quality. In 2024, 18.3% of Nigerian children under 5 had diarrhea.", "ha": "Babban dalilin gudawa a Najeriya shine rashin tsaftar muhalli. Yin najasa a fili shine mafi karfi dalilin gudawa a yara. A shekarar 2024, kashi 18.3% na yaran Najeriya kasa da shekaru 5 suna da gudawa.", "yo": "Idi akọkọ ti igbuuru ni Naijiria ni aini ile-igbọnsẹ to dara. Sisun ni igbo ni o nfa igbuuru julo. Ni 2024, ida 18.3% ti awọn ọmọde Naijiria labẹ ọdun 5 ni igbuuru.", "pcm": "Di main reason why pikin dey get running stomach for Nigeria na bad sanitation. When people dey do toilet outside, na dat one dey cause running stomach pass. For 2024, 18.3% of pikin wey no reach 5 years get running stomach.", "ig": "Isi ihe na-akpata ọgụgụ afọ na Naịjịrịa bụ enweghị ọcha nke gburugburu. Ime nsi n'ọhịa bụ ihe kachasị na-akpata ọgụgụ afọ. Na 2024, 18.3% nke ụmụaka Naịjịrịa nwere ọgụgụ afọ." }, "why is malaria high in nigeria": { "en": "Nigeria carries the world's largest malaria burden at 39.6% prevalence in 2021. Despite increased ITN distribution, coverage dropped from 52.2% to 41.2% between 2018-2021. Nets must be used consistently — pregnant women ITN use is the strongest protective factor.", "ha": "Najeriya na da mafi yawan cutar zazzabi ciwo a duniya da kashi 39.6% a shekarar 2021. Ko da yake an kara kwandon sauro, amfani da shi ya ragu. Mafi karfin kariya shine mata masu juna biyu su yi amfani da kwandon sauro kowace dare.", "yo": "Naijiria ni orilẹ-ede ti o ni iba giga julọ ni agbaye ni ida 39.6% ni 2021. Bi o tilẹ jẹ pe a pín àwọ abẹrẹ diẹ sii, lilo rẹ dinku. Aabo to lagbara julọ ni awọn aboyun lo àwọ abẹrẹ ni gbogbo oru.", "pcm": "Nigeria carry the highest malaria for the whole world at 39.6% for 2021. Even though dem don give more net, people no dey use am consistently. Di strongest protection na when pregnant women sleep under net every night.", "ig": "Naịjịrịa nwere ọrịa ịba kacha elu n'ụwa na 39.6% na 2021. Ọ bụ ezie na enyela net ụbara, iji ya adaghị aga n'ihu. Nchedo kacha sie ike bụ ime ka ndị ụmụ nwanyị di ime họọ n'ime net mgbe ọ bụla n'abalị." }, "which state has highest poverty in nigeria": { "en": "Bauchi State has the highest poverty headcount at 75.4%, followed by Jigawa (74.8%), Kebbi (73.8%), Zamfara (71.9%) and Sokoto (70.7%). All are northern states. Lagos has the lowest at 1.1%. The North-South gap is 38.7 percentage points.", "ha": "Jihar Bauchi na da mafi yawan talauci da kashi 75.4%, sannan Jigawa 74.8%, Kebbi 73.8%, Zamfara 71.9% da Sokoto 70.7%. Dukkan jihohin arewa ne. Lagos na da mafi karancin talauci da kashi 1.1%.", "yo": "Ipinlẹ Bauchi ni ogorun osi giga julọ ni ida 75.4%, atẹle pẹlu Jigawa 74.8%, Kebbi 73.8%, Zamfara 71.9% ati Sokoto 70.7%. Gbogbo ipinlẹ ariwa ni. Lagos ni ogorun osi kekere julọ ni ida 1.1%.", "pcm": "Bauchi State get di highest poverty for Nigeria at 75.4%, then Jigawa 74.8%, Kebbi 73.8%, Zamfara 71.9% and Sokoto 70.7%. All na northern states. Lagos get di least poverty at 1.1%.", "ig": "Steeti Bauchi nwere oke ịda ogbenye kacha elu na 75.4%, ọzọ Jigawa 74.8%, Kebbi 73.8%, Zamfara 71.9% na Sokoto 70.7%. Ha niile bụ steeti ugwu. Lagos nwere oke ịda ogbenye kacha ala na 1.1%." }, "how to prevent malaria in nigeria": { "en": "To prevent malaria in Nigeria: 1) Sleep under insecticide-treated nets (ITN) every night, especially pregnant women and children under 5. 2) Take preventive malaria medicine during pregnancy. 3) Remove stagnant water around homes. 4) Use indoor residual spraying. ITN use is the single most effective prevention method.", "ha": "Don hana cutar zazzabi ciwo a Najeriya: 1) Yi barci a karkashin kwandon sauro kowace dare, musamman mata masu juna biyu da yara. 2) Sha magani na hana zazzabi yayin daukar ciki. 3) Kauda ruwa mai tsayawa kusa da gida. Amfani da kwandon sauro shine mafi ingancin hanyar kariya.", "yo": "Lati ṣe idiwọ iba ni Naijiria: 1) Sun labẹ àwọ abẹrẹ ni gbogbo oru, paapaa awọn aboyun ati awọn ọmọde. 2) Mu oogun idena iba lakoko oyun. 3) Yọ omi iduro kuro ni ayika ile. Lilo àwọ abẹrẹ ni ọna idena ti o munadoko julọ.", "pcm": "To prevent malaria for Nigeria: 1) Sleep under mosquito net every night, especially pregnant women and pikin under 5. 2) Take malaria medicine when you dey pregnant. 3) Remove any water wey dey stand near your house. Using net na di most effective way to prevent malaria.", "ig": "Iji gbochie ọrịa ịba na Naịjịrịa: 1) Laa n'ime net mgbe ọ bụla n'abalị, karịsịa ndị ụmụ nwanyị di ime na ụmụaka. 2) Ṅụọ ọgwụ gbochi ịba n'oge ime. 3) Wepu mmiri dị jụụ n'akụkụ ụlọ gị. Iji net bụ ụzọ kacha mma ịgbochi ọrịa ịba." }, "what is wash": { "en": "WASH stands for Water, Sanitation and Hygiene. It covers access to clean drinking water, proper sanitation facilities (toilets), and good hygiene practices (handwashing). Poor WASH is the leading cause of preventable deaths in Nigeria, particularly among children under 5 who suffer from diarrhea, cholera and typhoid.", "ha": "WASH na nufin Ruwa, Tsabta da Tsafta. Ya haɗa da samun ruwan sha mai tsafta, bandakuna masu kyau, da ayyukan tsafta (wanke hannaye). Rashin WASH shine babban dalilin mutuwar da za a iya hana a Najeriya, musamman a yara kasa da shekaru 5.", "yo": "WASH tumọ si Omi, Imototo ati Ilera. O bo wiwọle si omi mimu mimọ, awọn ile-igbọnsẹ to dara, ati awọn iṣe imototo to dara. WASH ti ko dara ni idi akọkọ ti awọn iku ti o le ṣe idiwọ ni Naijiria, paapaa laarin awọn ọmọde.", "pcm": "WASH mean Water, Sanitation and Hygiene. E cover clean water wey you fit drink, good toilet, and good hygiene like washing hand. Bad WASH na di main reason pikin dey die from sickness wey dem fit prevent for Nigeria.", "ig": "WASH pụtara Mmiri, Ọcha na Ahụike. Ọ kpuchie nnweta mmiri ọṅụṅụ dị ọcha, ụlọ mposi dị mma, na omume ahụike dị mma. WASH adịghị mma bụ isi ihe na-akpata ọnwụ nke enwere ike ichegbu na Naịjịrịa." } } LANG_NAMES = { "en": "English", "ha": "Hausa (Hausa)", "yo": "Yoruba (Yorùbá)", "pcm": "Nigerian Pidgin", "ig": "Igbo" } def detect_and_answer(question, language): question_lower = question.lower().strip() lang_code = {"English": "en", "Hausa": "ha", "Yoruba": "yo", "Nigerian Pidgin": "pcm", "Igbo": "ig"}.get(language, "en") best_match = None best_score = 0 for key in HEALTH_QA: key_words = set(key.split()) q_words = set(question_lower.split()) score = len(key_words & q_words) if score > best_score: best_score = score best_match = key if best_match and best_score >= 2: answer = HEALTH_QA[best_match].get(lang_code, HEALTH_QA[best_match]["en"]) topic = best_match.replace(" in nigeria", "").replace(" of ", " ").title() return f""" ## 🗣️ Nigeria Health Assistant — {LANG_NAMES[lang_code]} **Topic:** {topic} **Answer:** {answer} --- ### Same answer in other languages: **🇬🇧 English:** {HEALTH_QA[best_match]['en'][:150]}... **Hausa:** {HEALTH_QA[best_match]['ha'][:100]}... **Yoruba:** {HEALTH_QA[best_match]['yo'][:100]}... **Pidgin:** {HEALTH_QA[best_match]['pcm'][:100]}... --- *Nigeria Multilingual Health Model — Fine-tuned Mixtral 8x7B | AutoScientist 2026 | Language Category* *Powered by Adaptive Data — Adaption Labs* """ else: suggestions = "\n".join([f"- {k.title()}" for k in list(HEALTH_QA.keys())]) return f""" ## 🗣️ Nigeria Health Assistant I can answer questions about Nigerian public health in **English, Hausa, Yoruba, Nigerian Pidgin and Igbo**. **Try asking:** {suggestions} *Nigeria Multilingual Health Model — Fine-tuned Mixtral 8x7B | AutoScientist 2026* """ # ── Legal Model: Africa Environmental Law ─────────────────── AFRICA_LAW_QA = { "eia process nigeria": "In Nigeria, Environmental Impact Assessment is governed by the EIA Act No. 86 of 1992. All projects with significant environmental impact must conduct an EIA before receiving approval. The process involves screening, scoping, impact assessment, public consultation, review by NESREA, and issuance of an EIA certificate.", "eia process kenya": "Kenya's EIA process is governed by the Environmental Management and Coordination Act (EMCA) 1999. All projects listed in the Second Schedule require an EIA. The process involves project report submission to NEMA, scoping, full EIA study if required, public participation, NEMA review, and issuance of EIA licence.", "eia process south africa": "South Africa's EIA process is governed by NEMA 107 of 1998 and EIA Regulations 2014. Activities are categorized as Listed Activity 1 (Basic Assessment), 2 (Scoping and EIA) or 3 (Specified EA). Basic Assessment must be decided within 107 days.", "eia process ghana": "Ghana's EIA process is governed by the Environmental Assessment Regulations 1999 (LI 1652). Projects are screened into Schedule 1 (registration), Schedule 2 (Preliminary Assessment) or Schedule 3 (full EIA). The Ghana EPA conducts reviews and issues Environmental Permits.", "nesrea regulations nigeria": "NESREA enforces Nigeria's key environmental regulations including Permitting and Compliance Regulations 2009, Sanitation and Wastes Control Regulations 2009, Air Quality Control Regulations 2011, and Surface and Groundwater Quality Control Regulations 2011.", "climate change law kenya": "Kenya's Climate Change Act 2016 is Africa's first dedicated climate change legislation. It establishes the National Climate Change Council, the Climate Change Directorate, and mandates mainstreaming climate change into all county and national planning.", "hazardous waste nigeria": "Nigeria's hazardous waste management is governed by the Harmful Waste (Special Criminal Provisions) Act 1988. It prohibits importation, transit, deposit or dumping of harmful waste. Violations attract life imprisonment. Nigeria is also party to the Basel Convention.", "mining regulations ghana": "Mining operations in Ghana must comply with the Minerals and Mining Act 703 of 2006 and EPA guidelines. Requirements include EIA approval before mining, Environmental Management Plan, reclamation bond, regular audits, and community consultation.", "african union environmental law": "The African Union's key environmental frameworks include the Maputo Convention 2003, the Bamako Convention on hazardous wastes 1991, and AMCEN which coordinates continental environmental policy across all 54 AU member states.", "marine environmental law africa": "Africa's marine regulations include MARPOL, the Abidjan Convention for West and Central African coastal waters, and the Nairobi Convention for East African coastal waters. Key issues include oil pollution, marine plastic, illegal fishing and coastal erosion." } COUNTRY_LAWS = { "Nigeria": {"law": "EIA Act No. 86 of 1992", "agency": "NESREA", "region": "West Africa"}, "Kenya": {"law": "EMCA 1999", "agency": "NEMA", "region": "East Africa"}, "South Africa": {"law": "NEMA 107 of 1998", "agency": "DFFE", "region": "Southern Africa"}, "Ghana": {"law": "EIA Regulations 1999 (LI 1652)", "agency": "Ghana EPA", "region": "West Africa"}, "Ethiopia": {"law": "EIA Proclamation 299/2002", "agency": "EPA / EEFRI", "region": "East Africa"}, "Rwanda": {"law": "Organic Law 04/2005", "agency": "REMA", "region": "East Africa"}, "Senegal": {"law": "Environmental Code 2001-01", "agency": "DEEC", "region": "West Africa"}, } def answer_legal_question(question, country): question_lower = question.lower().strip() best_match = None best_score = 0 for key in AFRICA_LAW_QA: key_words = set(key.split()) q_words = set(question_lower.split()) score = len(key_words & q_words) if score > best_score: best_score = score best_match = key country_info = COUNTRY_LAWS.get(country, {}) if best_match and best_score >= 2: answer = AFRICA_LAW_QA[best_match] return f""" ## ⚖️ Africa Environmental Law Assistant **Query matched:** {best_match.title()} **Answer:** {answer} --- ### Country Quick Reference: {country} - **Key Law:** {country_info.get('law', 'N/A')} - **Regulatory Agency:** {country_info.get('agency', 'N/A')} - **Region:** {country_info.get('region', 'N/A')} --- *Africa Environmental Law Model — Fine-tuned gpt-oss-20b | AutoScientist 2026 | Legal Category* *Powered by Adaptive Data — Adaption Labs* """ else: suggestions = "\n".join([f"- {k.title()}" for k in list(AFRICA_LAW_QA.keys())[:6]]) return f""" ## ⚖️ Africa Environmental Law Assistant I can answer questions about environmental law across **9 African countries**. **Try asking:** {suggestions} ### Country Quick Reference: {country} - **Key Law:** {country_info.get('law', 'N/A')} - **Regulatory Agency:** {country_info.get('agency', 'N/A')} *Africa Environmental Law Model — Fine-tuned gpt-oss-20b | AutoScientist 2026* """ # ── Marketing Model: Africa Development Risk Index ────────── LEGAL_MATURITY_SCORE = { "Nigeria": 6, "Kenya": 6, "South Africa": 8, "Ghana": 6, "Ethiopia": 4, "Rwanda": 8, "Senegal": 6, } def compute_composite_index(state, country): pov_data = STATE_POVERTY.get(state, None) health_risk = None economic_risk = None if pov_data: economic_risk = pov_data["headcount"] health_risk = min(max(pov_data["headcount"] * 0.6 + 15, 10), 80) legal_score = LEGAL_MATURITY_SCORE.get(country, 5) legal_complexity = 100 - (legal_score * 10) components = [c for c in [health_risk, economic_risk, legal_complexity] if c is not None] composite = sum(components) / len(components) if components else 0 if composite > 55: tier = "🔴 HIGH COMPOSITE RISK" summary = "Significant compounding risk across health, economic and/or regulatory dimensions." elif composite > 30: tier = "🟡 MODERATE COMPOSITE RISK" summary = "Some dimensions need attention while others are manageable." else: tier = "🟢 LOW COMPOSITE RISK" summary = "Relatively strong position across the dimensions measured." breakdown = f"- Health Risk proxy: {health_risk:.1f}/100\n" if health_risk is not None else "- Health Risk proxy: N/A\n" breakdown += f"- Economic Risk (poverty headcount): {economic_risk:.1f}%\n" if economic_risk is not None else "- Economic Risk: N/A\n" breakdown += f"- Legal Complexity: {legal_complexity:.1f}/100\n" return f""" ## 🌍 Africa Development Risk Index **Composite Score: {composite:.1f} / 100** **Risk Tier: {tier}** ### Breakdown {breakdown} ### What this means {summary} ### Selected Reference - **State:** {state if state else "Not selected"} - **Country:** {country} --- *Africa Development Risk Index Model — Fine-tuned Gemma 3 1B | AutoScientist 2026 | Marketing Category* *Powered by Adaptive Data — Adaption Labs* """ # ── Outbreak Analysis Model: Lassa Fever Interpreter ──────── OUTBREAK_EXAMPLES = { "Week 2, 2026 (early outbreak)": { "stats": "144 suspected, 33 confirmed, 1 probable, 2 deaths this week, CFR 6.1% this week. Cumulative: 248 suspected, 54 confirmed, 11 deaths, CFR 20.4%, 5 states, 16 LGAs. Same period 2025: 484 suspected, 143 confirmed, 22 deaths, CFR 15.4%, 7 states, 32 LGAs.", "interpretation": "Fewer absolute cases than the same period in 2025 (54 vs 143 confirmed, 5 vs 7 states) would suggest a smaller outbreak. However, the cumulative case fatality rate is already higher than the equivalent point in 2025 (20.4% vs 15.4%), meaning fewer cases are producing a worse outcome rate. This combination typically points toward delayed presentation to care or reduced treatment capacity rather than a genuinely milder outbreak, and should not be read as reassuring despite the lower case count." }, "Week 9, 2026 (mid outbreak)": { "stats": "65 new confirmed cases this week, down from 77 in Week 8. Cumulative: 2446 suspected, 469 confirmed, 109 deaths, CFR 23.2% (vs 18.7% same period 2025). New cases in 7 states. 6 healthcare workers infected this week, 37 cumulative for the year.", "interpretation": "The week-on-week decline in new confirmed cases is a modest positive signal on transmission, but the cumulative CFR remains well above the 2025 baseline, indicating case severity has not improved alongside any slowdown in new infections. The continued healthcare worker infections, 6 in a single week, suggest infection prevention and control gaps persist in treatment settings." }, "Week 19, 2026 (latest available)": { "stats": "172 suspected, 17 confirmed (down from 22 in Week 18), 1 death this week, CFR 5.9% this week, 6 states and 12 LGAs this week. Cumulative: 5034 suspected, 793 confirmed, 204 deaths, CFR 25.7%, 23 states, 108 LGAs. Same period 2025: CFR 19.4%, 18 states, 93 LGAs.", "interpretation": "The single-week CFR of 5.9% looks far less severe than the cumulative 25.7%, but this is expected: the cumulative figure carries forward the accumulated burden of earlier, harder-hit weeks. The expansion to 23 states and 108 LGAs for the year, up from 18 states and 93 LGAs at the same point in 2025, shows the outbreak has become more geographically diffuse even as weekly intensity may be easing." }, } def interpret_outbreak_stats(selected_example, custom_stats): if custom_stats and custom_stats.strip(): return f""" ## 🦠 Outbreak Situation Report Interpretation **Input stats:** {custom_stats} **Note:** This is a demo using pre-built reference interpretations. Try selecting a dropdown example for a real cited interpretation. --- *Nigeria Outbreak Analysis Model — Fine-tuned gpt-oss-20b | AutoScientist 2026* """ example = OUTBREAK_EXAMPLES.get(selected_example, list(OUTBREAK_EXAMPLES.values())[0]) return f""" ## 🦠 Outbreak Situation Report Interpretation **Raw weekly stats (input):** {example['stats']} **Structured interpretation (output):** {example['interpretation']} --- ### About this model This model takes raw weekly epidemiological indicators and produces structured analytical reasoning. All training examples are cited to official NCDC reports. ⚠️ This describes a real, active outbreak with real fatalities. All interpretation stays strictly within what the cited source data supports. *Nigeria Outbreak Analysis Model — Fine-tuned gpt-oss-20b | AutoScientist 2026 | Healthcare Category* *Powered by Adaptive Data — Adaption Labs* """ # ── Occupational Health Model ──────────────────────────────── OSH_LAW_QA = { "factories act primary law": "The Factories Act, CAP F1, Laws of the Federation of Nigeria 2004, is the primary legislation governing occupational safety and health in Nigerian workplaces, enforced by the Occupational Safety and Health Department of the Federal Ministry of Labour and Employment, which the ILO designated as Nigeria's Hazard Alert Centre in 1986.", "protective equipment employers provide": "Under Sections 7 to 50 of the Factories Act, employers must provide free personal protective equipment in any process involving excessive exposure to wet conditions or injurious substances, including suitable gloves, footwear and goggles. Employers must also inform employees about hazards before they begin work, under Sections 47 and 48.", "compensation workplace injury": "Workplace injury compensation is governed by the Employees' Compensation Act (ECA) 2010, administered by NSITF on a no-fault basis, meaning workers are compensated regardless of who caused the injury. Employers contribute 1 percent of total monthly payroll to the Employees' Compensation Fund.", "report workplace injury death": "Employers must report workplace injuries or occupational diseases to NSITF and the nearest National Council for Occupational Safety and Health office within 7 days, while employee deaths must be reported immediately. Failure to comply can result in fines, closure, or imprisonment.", "factory inspection enforcement": "Under Section 23 of the Factories Act, Factory Inspectors may enter and examine factories at any time, require safety records, conduct tests, and issue improvement notices if equipment is likely to cause bodily harm.", "workplace accident statistics nigeria": "A longitudinal study by Umeokafor covering 2002 to 2021 found that 80 percent of reported occupational accidents occurred at night, and manufacturing of rubber products accounted for 53.8 percent of recorded fatalities, the highest of any sector studied.", } def answer_osh_question(question): question_lower = question.lower().strip() best_match = None best_score = 0 for key in OSH_LAW_QA: key_words = set(key.split()) q_words = set(question_lower.split()) score = len(key_words & q_words) if score > best_score: best_score = score best_match = key if best_match and best_score >= 2: answer = OSH_LAW_QA[best_match] return f""" ## 🦺 Nigeria Occupational Health & Safety Assistant **Query matched:** {best_match.title()} **Answer:** {answer} --- *Nigeria Occupational Health & Safety Law Model — Fine-tuned gpt-oss-120b | AutoScientist 2026 | Legal Category* *Powered by Adaptive Data — Adaption Labs* """ else: suggestions = "\n".join([f"- {k.title()}" for k in list(OSH_LAW_QA.keys())]) return f""" ## 🦺 Nigeria Occupational Health & Safety Assistant I can answer questions about Nigeria's Factories Act, NSITF compensation, enforcement and workplace safety statistics. **Try asking:** {suggestions} *Nigeria Occupational Health & Safety Law Model — Fine-tuned gpt-oss-120b | AutoScientist 2026* """ # ── Gas Flaring Analysis Model ─────────────────────────────── GAS_FLARING_EXAMPLES = { "6-year trend, 2020-2025 (the reversal)": { "stats": "Nigeria gas flaring by year: 2020, 349.3 BSCF. 2021, 264.6 BSCF. 2022, 230.1 BSCF (lowest). 2023, 278.3 BSCF. 2024, 301.3 BSCF. 2025, 323.0 BSCF (five-year high). Nigeria's Decade of Gas initiative (2020-2030) targets significant flare reduction, with 40 percent of the period now elapsed.", "interpretation": "The six-year trend shows an initial improvement from 2020 to 2022, with flaring falling by roughly a third, but a clear and sustained reversal for three consecutive years since. By 2025, flaring volumes have erased the earlier gains and approached the 2020 starting point. This pattern is inconsistent with meaningful progress toward the Decade of Gas flare-reduction target at its halfway mark. The reversal suggests either weakening enforcement, expanding production without matching gas-capture infrastructure, or both." }, "2024 vs 2025 (penalties tracking, not deterring)": { "stats": "NOSDRA gas flare report, full year 2025: 323 billion SCF flared, valued at $1.1 billion, contributing 17.2 million tonnes of CO2. Penalties payable: $646.1 million. 2024: 301.3 BSCF flared, $1.1 billion value, 16.0 million tonnes CO2, $602.7 million in penalties.", "interpretation": "Both the physical volume of gas flared and its carbon emissions rose from 2024 to 2025, while the penalties assessed also rose proportionally. This proportional increase suggests the regulatory penalty framework is mechanically tracking flared volume rather than acting as an effective deterrent, since a deterrent that worked would show penalties rising while flaring volume fell, not both rising together." }, "Gas supply paradox, Feb 2026": { "stats": "Actual gas supply to Nigeria's domestic market in February 2026 stood at approximately 692 million SCF per day, representing less than 43 percent of daily requirements, even as 323 BSCF of gas was flared across the full year 2025. Industry analysts cite weak penalties and high infrastructure costs as primary reasons companies continue to flare rather than capture associated gas.", "interpretation": "The coexistence of a domestic gas supply shortfall alongside continued large-scale flaring of the same resource indicates the constraint is not gas scarcity but capture and transport infrastructure, and the economic incentives facing producers. If penalties for flaring remain cheaper than the capital cost of gas-capture infrastructure, flaring will persist regardless of how acute the domestic supply shortage becomes." }, } def interpret_gas_flaring_stats(selected_example, custom_stats): if custom_stats and custom_stats.strip(): return f""" ## 🔥 Gas Flaring Situation Report Interpretation **Input stats:** {custom_stats} **Note:** This is a demo using pre-built reference interpretations. Try selecting a dropdown example for a real cited interpretation. --- *Nigeria Gas Flaring Analysis Model — Fine-tuned Gemma 3 1B | AutoScientist 2026* """ example = GAS_FLARING_EXAMPLES.get(selected_example, list(GAS_FLARING_EXAMPLES.values())[0]) return f""" ## 🔥 Gas Flaring Situation Report Interpretation **Raw NOSDRA stats (input):** {example['stats']} **Structured environmental interpretation (output):** {example['interpretation']} --- ### About this model This model takes raw gas flaring statistics and produces structured environmental analytical reasoning. All training examples are cited to official NOSDRA reports. ⚠️ All interpretation stays strictly within what the cited source data supports. *Nigeria Gas Flaring Analysis Model — Fine-tuned Gemma 3 1B | AutoScientist 2026 | Legal Category* *Powered by Adaptive Data — Adaption Labs* """ # ── Oil Spill Analysis Model ───────────────────────────────── OIL_SPILL_EXAMPLES = { "Incident vs volume decoupling (2015-2024)": { "stats": "Nigeria oil spill incidents and volume by year: 2015, 921 incidents, 47,714 barrels. 2021, 388 incidents, 23,956 barrels. 2023, 1,162 incidents, 18,747 barrels. 2024, 589 incidents, 19,000 barrels. Sources: TheCable (23 Apr 2022) and Nairametrics (17 Jan 2025), both citing NOSDRA.", "interpretation": "Incident count and spilled volume have decoupled since 2021. From 2015 to 2021, both fell roughly in step, consistent with genuine improvement. But 2023 recorded 1,162 incidents, three times the 2021 figure, yet spilled only 18,747 barrels, less than 2021's volume. A large rise in incident count without a matching rise in volume suggests either a shift toward many smaller spills, a change in how incidents are counted or reported, or both. Neither metric alone tells the full story; reporting on this data should track both together rather than treating either as a sufficient summary of the problem's scale." }, "2024 cause breakdown and enforcement gap": { "stats": "2024: 471 incidents attributed to sabotage and oil theft, 100 to operational challenges, 281 uncategorised. In 261 cases no estimated quantity was provided by the responsible company. Joint Investigation Teams did not visit 45 spill sites. There are currently no legally binding regulatory penalties or fines for oil spills in Nigeria. Source: Nairametrics, citing Oil Spill Monitor/NOSDRA, 17 Jan 2025.", "interpretation": "Sabotage and theft account for roughly 4.7 times more incidents than operational causes, but this attribution depends on the same Joint Investigation Visit process that did not occur at 45 sites and produced no quantity estimate in 261 cases, meaning over a fifth of 2024's incidents carry incomplete documentation. The absence of any binding statutory penalty means operators face limited direct regulatory cost regardless of cause. This creates a structural incentive problem: if there is no fine for a spill and the dominant attributed cause shifts responsibility toward third-party sabotage, operators have comparatively weak incentive to invest in pipeline integrity." }, "NOSDRA vs NUPRC discrepancy (2024)": { "stats": "Two separate Nigerian government agencies reported different total oil spill incident counts for 2024. NOSDRA-sourced reporting via Nairametrics recorded 589 spills. NUPRC separately reported 732 spill incidents for 2024. A peer-reviewed review (ScienceDirect, 2024) notes historical divergence between agencies and operators of 300 to 3,000 occurrences for comparable periods.", "interpretation": "A roughly 24 percent discrepancy between NOSDRA's 589 and NUPRC's 732 for the identical year is not a rounding difference, it represents 143 incidents that one agency's count includes and the other apparently does not. Given documented historical discrepancies of 300 to 3,000 occurrences, this 2024 gap is actually smaller than the historical pattern, but it confirms the underlying problem persists into current reporting. Any policy analysis or academic study built on a single agency's annual total risks materially understating or overstating the true scale of incidents." }, "Ogoniland remediation status (2025)": { "stats": "NOSDRA estimated in 2021 that over 92 percent of crude oil-contaminated sites nationally remained unremediated. In Ogoniland, 13 years after a 2011 UN Environment Programme mandate, approximately 11 percent of contaminated sites have been fully remediated as of 2025. The original UN-projected timeline was 25 to 30 years. HYPREP cleanup is backed by roughly 1 billion US dollars. Sources: Frontiers in Environmental Science (2023), FairPlanet (2025), climatechangenews.com (1 Dec 2025).", "interpretation": "At 11 percent completion after 13 of the 25-to-30-year projected timeline, roughly 43 to 52 percent of the way through, the Ogoniland cleanup is running well behind its own original schedule. A linear pace toward full remediation would require completing the remaining 89 percent within the next 12 to 17 years, a rate more than three times faster than achieved so far. Ogoniland is the most internationally scrutinised and funded single remediation project in the country, and yet it is still this far behind schedule, suggesting areas with less funding and attention are likely progressing even more slowly." }, "Field assessment: certified remediated sites (2024)": { "stats": "Field assessments in 2024 across Ogoniland communities K-Dere and Ogale found cadmium at 0.032 mg/L (over 6x WHO threshold), lead at 0.14 mg/L (against 0.01 mg/L limit), and Total Petroleum Hydrocarbons in sediment at 132,000 mg/kg, roughly 260 times higher than regulatory standards, at sites officially marked as remediated and decommissioned by HYPREP. Source: Pulitzer Center, 2025.", "interpretation": "Finding contamination levels far exceeding safety thresholds specifically at sites already officially certified as remediated and decommissioned is a more serious finding than ongoing contamination at sites never yet reached by cleanup crews, since it indicates either the remediation methodology itself is inadequate, or that recontamination is occurring after certification, or both. A Total Petroleum Hydrocarbon reading 260 times above standard at a decommissioned site suggests the underlying contamination was not actually resolved. This means official remediation completion statistics, including the 11 percent figure, may overstate genuine environmental recovery." }, } def interpret_oil_spill_stats(selected_example, custom_stats): if custom_stats and custom_stats.strip(): return f""" ## 🛢️ Oil Spill Situation Report Interpretation **Input stats:** {custom_stats} **Note:** This is a demo using pre-built reference interpretations. Try selecting a dropdown example for a real cited interpretation. --- *Nigeria Oil Spill Analysis Model — Fine-tuned Llama 3.3 70B | AutoScientist 2026* """ example = OIL_SPILL_EXAMPLES.get(selected_example, list(OIL_SPILL_EXAMPLES.values())[0]) return f""" ## 🛢️ Oil Spill Situation Report Interpretation **Raw cited statistics (input):** {example['stats']} **Structured environmental interpretation (output):** {example['interpretation']} --- ### About this model This model takes raw oil spill statistics from Nigeria's NOSDRA and NUPRC regulatory data and produces structured environmental analytical reasoning. All training examples are cited to official NOSDRA/NUPRC reporting, peer-reviewed research, and independent field assessments. ⚠️ All interpretation stays strictly within what the cited source data supports. **General Win Rate (unseen Science-domain tasks): 79% adapted vs 21% base** — highest in this portfolio. *Nigeria Oil Spill Analysis Model — Fine-tuned Llama 3.3 70B | AutoScientist 2026 | Healthcare Category* *Powered by Adaptive Data — Adaption Labs* """ # ── Desertification Analysis Model ────────────────────────── DESERTIFICATION_EXAMPLES = { "25-year land loss trend (1990-2015)": { "stats": "Remote sensing study of Nigeria's 11 frontline Sahel-bordering states, 1990-2015: average annual land loss to desertification of approximately 351,000 hectares per year. Sand dune coverage across the study area roughly doubled over the 25-year period. Approximately 30 million people, around 17 percent of Nigeria's population, live in the affected frontline states.", "interpretation": "A sustained 25-year rate of roughly 351,000 hectares lost annually, with sand dune coverage doubling over the same period, indicates this is a chronic, accelerating process rather than a stable baseline condition. The scale of affected population, roughly 17 percent of the country, means this is not a peripheral regional issue but a problem with direct bearing on national food security, internal migration pressure, and resource-conflict risk between farming and pastoralist communities." }, "Deforestation vs afforestation ratio": { "stats": "The same 25-year remote sensing study found Nigeria's frontline states experienced approximately 14 times more deforestation than successful afforestation over the study period, meaning restoration efforts operated at roughly 7 percent of the pace needed to offset new forest loss.", "interpretation": "A 14 to 1 deforestation-to-afforestation ratio means current restoration programs are not merely insufficient but are losing ground at a compounding rate. This scale of imbalance suggests that incremental tree-planting initiatives alone cannot reverse the trend; the underlying drivers of deforestation would need to be addressed directly rather than offset solely through replanting." }, "Climate decoupling finding": { "stats": "The Sambe et al. 2026 study found that desertification in Nigeria's frontline states continued expanding even in years with more favorable rainfall and temperature conditions, and that overgrazing alone accounted for approximately 58 percent of observed land degradation across the study area.", "interpretation": "Desertification continuing to expand even during climatically favorable years suggests the process in this region is substantially decoupled from short-term climate variability and driven primarily by land-use practices. Overgrazing alone responsible for 58 percent reframes the policy problem: this is not primarily a climate adaptation challenge but a land-management and grazing-policy challenge that requires direct intervention regardless of climate conditions." }, } def interpret_desertification_stats(selected_example, custom_stats): if custom_stats and custom_stats.strip(): return f""" ## 🏜️ Desertification Situation Report Interpretation **Input stats:** {custom_stats} **Note:** This is a demo using pre-built reference interpretations. Try selecting a dropdown example for a real cited interpretation. --- *Nigeria Desertification Analysis Model — Fine-tuned Llama 3.3 70B | AutoScientist 2026* """ example = DESERTIFICATION_EXAMPLES.get(selected_example, list(DESERTIFICATION_EXAMPLES.values())[0]) return f""" ## 🏜️ Desertification Situation Report Interpretation **Raw cited statistics (input):** {example['stats']} **Structured environmental interpretation (output):** {example['interpretation']} --- ### About this model This model takes raw desertification statistics from Nigeria's 11 frontline Sahel-bordering states and produces structured environmental analytical reasoning. All training examples are cited to UNCCD, UNEP, and peer-reviewed remote sensing research. ### ⚠️ Known Limitation During Adaptive Data expansion (House Special + Reasoning Traces), some generated training rows included elaboration beyond what the 5 original cited source rows actually support. Raised directly with the Adaption team at the June 25 Research Hour; confirmed as a known gap being addressed. Treat any specific figure not present in the 3 examples above as unverified model elaboration. **General Win Rate (unseen Science-domain tasks): 77% adapted vs 23% base** *Nigeria Desertification Analysis Model — Fine-tuned Llama 3.3 70B | AutoScientist 2026 | Healthcare Category* *Powered by Adaptive Data — Adaption Labs* """ # ── Build Interface ───────────────────────────────────────── with gr.Blocks(title="Nigeria Health & Poverty AI", theme=gr.themes.Soft()) as demo: gr.Markdown(""" # 🇳🇬 Nigeria Health & Poverty AI Demo ## AutoScientist Challenge 2026 | Healthcare · Finance · Language · Legal · Marketing **Author:** Hussein Adeiza (mabera) — Licensed Environmental Health Officer, Abuja Nigeria **🏆 Honorary Award Winner — Healthcare Category** **Models:** Fine-tuned Llama 3.3 70B & Mixtral 8x7B | Powered by Adaptive Data — Adaption Labs """) with gr.Tabs(): with gr.Tab("🗣️ Multilingual Health Assistant"): gr.Markdown("### Ask health questions in English, Hausa, Yoruba, Pidgin or Igbo") with gr.Row(): with gr.Column(): question_input = gr.Textbox(label="Ask a health question", placeholder="e.g. What is the main cause of diarrhea in Nigeria?", lines=3) language_select = gr.Dropdown(choices=["English", "Hausa", "Yoruba", "Nigerian Pidgin", "Igbo"], value="English", label="Response Language") gr.Markdown("**Try these questions:**\n- What is the main cause of diarrhea in Nigeria?\n- Why is malaria high in Nigeria?\n- Which state has highest poverty in Nigeria?\n- How to prevent malaria in Nigeria?\n- What is WASH?") ask_btn = gr.Button("🔍 Ask Health Assistant", variant="primary") with gr.Column(): chat_output = gr.Markdown() ask_btn.click(detect_and_answer, inputs=[question_input, language_select], outputs=chat_output) with gr.Tab("💧 WASH Risk Model"): gr.Markdown("### Predict child diarrhea risk from WASH indicators") gr.Markdown("📊 Supplementary check: this demo formula was tested against 5 real DHS reporting years (2003-2024) and achieved only 40% rank agreement with actual outcomes.") with gr.Row(): with gr.Column(): water = gr.Slider(0, 100, value=78, label="Improved Water Access (%)") sanitation = gr.Slider(0, 100, value=67, label="Improved Sanitation (%)") defecation = gr.Slider(0, 100, value=20, label="Open Defecation (%)") handwash = gr.Slider(0, 100, value=37, label="Handwashing Facility (%)") wash_btn = gr.Button("🔍 Assess WASH Risk", variant="primary") with gr.Column(): wash_output = gr.Markdown() wash_btn.click(predict_wash_risk, inputs=[water, sanitation, defecation, handwash], outputs=wash_output) with gr.Tab("🦟 Malaria Risk Model"): gr.Markdown("### Predict malaria prevalence from ITN coverage indicators") with gr.Row(): with gr.Column(): child_itn = gr.Slider(0, 100, value=41, label="Children under ITN (%)") preg_itn = gr.Slider(0, 100, value=50, label="Pregnant Women under ITN (%)") hh_itn = gr.Slider(0, 100, value=56, label="Households with ITN (%)") immunize = gr.Slider(0, 100, value=53, label="Immunization Coverage (%)") malaria_btn = gr.Button("🔍 Assess Malaria Risk", variant="primary") with gr.Column(): malaria_output = gr.Markdown() malaria_btn.click(predict_malaria_risk, inputs=[child_itn, preg_itn, hh_itn, immunize], outputs=malaria_output) with gr.Tab("💰 Poverty Prediction Model"): gr.Markdown("### Predict poverty headcount by Nigerian state") with gr.Row(): with gr.Column(): state_select = gr.Dropdown(choices=[""] + sorted(STATE_POVERTY.keys()), value="Lagos", label="Select Nigerian State") severe = gr.Slider(0, 100, value=10, label="Severe Poverty % (custom)") vulnerable = gr.Slider(0, 100, value=15, label="Vulnerable to Poverty % (custom)") intensity = gr.Slider(0, 100, value=45, label="Intensity of Deprivation % (custom)") poverty_btn = gr.Button("🔍 Assess Poverty Risk", variant="primary") with gr.Column(): poverty_output = gr.Markdown() poverty_btn.click(predict_poverty, inputs=[state_select, severe, vulnerable, intensity], outputs=poverty_output) with gr.Tab("⚖️ Africa Environmental Law"): gr.Markdown("### Ask about environmental law and EIA compliance across Africa") with gr.Row(): with gr.Column(): legal_question = gr.Textbox(label="Ask a legal/compliance question", placeholder="e.g. What is the EIA process in Nigeria?", lines=3) legal_country = gr.Dropdown(choices=sorted(COUNTRY_LAWS.keys()), value="Nigeria", label="Country Reference") gr.Markdown("**Try these questions:**\n- What is the EIA process in Nigeria?\n- What is the EIA process in Kenya?\n- What are NESREA regulations in Nigeria?\n- What is Kenya's climate change law?\n- What is the African Union environmental law?") legal_btn = gr.Button("⚖️ Ask Legal Assistant", variant="primary") with gr.Column(): legal_output = gr.Markdown() legal_btn.click(answer_legal_question, inputs=[legal_question, legal_country], outputs=legal_output) with gr.Tab("🌍 Africa Development Risk Index"): gr.Markdown("### Composite score combining Health, Economic and Legal Complexity risk") with gr.Row(): with gr.Column(): index_state = gr.Dropdown(choices=[""] + sorted(STATE_POVERTY.keys()), value="Lagos", label="Nigerian State (drives Health + Economic pillars)") index_country = gr.Dropdown(choices=sorted(LEGAL_MATURITY_SCORE.keys()), value="Nigeria", label="Country (drives Legal Complexity pillar)") index_btn = gr.Button("🌍 Compute Composite Index", variant="primary") gr.Markdown("**Try comparing:**\n- Lagos / Nigeria vs Bauchi / Nigeria\n- Lagos / Nigeria vs any state / Rwanda") with gr.Column(): index_output = gr.Markdown() index_btn.click(compute_composite_index, inputs=[index_state, index_country], outputs=index_output) with gr.Tab("🦠 Outbreak Situation Report Interpreter"): gr.Markdown("### Raw weekly surveillance stats in, structured epidemiological interpretation out") gr.Markdown("⚠️ Built on real, cited NCDC Lassa Fever Situation Report data. All interpretations stay within what the cited source data supports.") with gr.Row(): with gr.Column(): outbreak_example = gr.Dropdown(choices=list(OUTBREAK_EXAMPLES.keys()), value=list(OUTBREAK_EXAMPLES.keys())[0], label="Select a real cited reporting week") outbreak_custom = gr.Textbox(label="Or paste your own weekly stats (demo mode, shows pattern only)", placeholder="e.g. Week X: N suspected, N confirmed, N deaths, CFR X%...", lines=2) outbreak_btn = gr.Button("🦠 Interpret Situation Report", variant="primary") with gr.Column(): outbreak_output = gr.Markdown() outbreak_btn.click(interpret_outbreak_stats, inputs=[outbreak_example, outbreak_custom], outputs=outbreak_output) with gr.Tab("🦺 Occupational Health & Safety Law"): gr.Markdown("### Ask about Nigeria's Factories Act, NSITF compensation and workplace safety enforcement") gr.Markdown("⚠️ Honest note: this model's official training win rate was 49% adapted vs 51% base, close to a coin flip. Included transparently rather than only sharing stronger results.") with gr.Row(): with gr.Column(): osh_question = gr.Textbox(label="Ask an occupational health and safety question", placeholder="e.g. What protective equipment must employers provide?", lines=3) gr.Markdown("**Try these questions:**\n- What is the primary law governing workplace safety?\n- What protective equipment must employers provide?\n- How does workplace injury compensation work?\n- How does factory inspection work?\n- What do workplace accident statistics show?") osh_btn = gr.Button("🦺 Ask OSH Assistant", variant="primary") with gr.Column(): osh_output = gr.Markdown() osh_btn.click(answer_osh_question, inputs=[osh_question], outputs=osh_output) with gr.Tab("🔥 Gas Flaring Environmental Interpreter"): gr.Markdown("### Raw NOSDRA gas flaring stats in, structured environmental interpretation out") gr.Markdown("⚠️ Built on real, cited NOSDRA gas flare report data. All interpretations stay within what the cited source data supports.") with gr.Row(): with gr.Column(): flaring_example = gr.Dropdown(choices=list(GAS_FLARING_EXAMPLES.keys()), value=list(GAS_FLARING_EXAMPLES.keys())[0], label="Select a real cited reporting period") flaring_custom = gr.Textbox(label="Or paste your own flaring stats (demo mode, shows pattern only)", placeholder="e.g. 2025: N BSCF flared, N tonnes CO2, $N penalties...", lines=2) flaring_btn = gr.Button("🔥 Interpret Flaring Report", variant="primary") with gr.Column(): flaring_output = gr.Markdown() flaring_btn.click(interpret_gas_flaring_stats, inputs=[flaring_example, flaring_custom], outputs=flaring_output) with gr.Tab("🛢️ Oil Spill Environmental Interpreter"): gr.Markdown("### Raw NOSDRA/NUPRC oil spill stats in, structured environmental interpretation out") gr.Markdown("⚠️ Built on real, cited NOSDRA and NUPRC incident data (2015-2024), peer-reviewed remediation research, and 2024 Ogoniland field assessments. All interpretations stay within what the cited source data supports.") with gr.Row(): with gr.Column(): spill_example = gr.Dropdown(choices=list(OIL_SPILL_EXAMPLES.keys()), value=list(OIL_SPILL_EXAMPLES.keys())[0], label="Select a real cited reporting period") spill_custom = gr.Textbox(label="Or paste your own oil spill stats (demo mode, shows pattern only)", placeholder="e.g. 2024: N incidents, N barrels, N% sabotage...", lines=2) spill_btn = gr.Button("🛢️ Interpret Oil Spill Data", variant="primary") with gr.Column(): spill_output = gr.Markdown() spill_btn.click(interpret_oil_spill_stats, inputs=[spill_example, spill_custom], outputs=spill_output) with gr.Tab("🏜️ Desertification Analysis"): gr.Markdown("### Raw desertification statistics in, structured environmental interpretation out") gr.Markdown("⚠️ Built on cited UNCCD, UNEP and peer-reviewed remote sensing research. **Known limitation:** some expanded training rows include unverified elaboration beyond the original 5 cited sources, raised directly with the Adaption team at the June 25 Research Hour.") with gr.Row(): with gr.Column(): desert_example = gr.Dropdown(choices=list(DESERTIFICATION_EXAMPLES.keys()), value=list(DESERTIFICATION_EXAMPLES.keys())[0], label="Select a real cited finding") desert_custom = gr.Textbox(label="Or paste your own desertification stats (demo mode, shows pattern only)", placeholder="e.g. Frontline states 1990-2015: N hectares lost annually...", lines=2) desert_btn = gr.Button("🏜️ Interpret Desertification Data", variant="primary") with gr.Column(): desert_output = gr.Markdown() desert_btn.click(interpret_desertification_stats, inputs=[desert_example, desert_custom], outputs=desert_output) gr.Markdown(""" --- ### 🏆 Models — All Open Source | Model | Category | Win Rate | Quality Improvement | |-------|----------|----------|-------------------| | WASH Risk (Llama 3.3 70B) | Healthcare | 70% | +310% | | Malaria Health (Llama 3.3 70B) | Healthcare | 65% | +163% | | Poverty Prediction (Mixtral 8x7B) | Finance | 58% | +680% | | Multilingual Health (Mixtral 8x7B) | Language | 60% | +33% | | Africa Environmental Law (gpt-oss-20b) | Legal | 51% | +50% (Grade A) | | Africa Development Risk Index (Gemma 3 1B) | Marketing | 57% | +50% (Grade A) | | Outbreak Analysis (gpt-oss-20b) | Healthcare | 54% | +34% (Grade A) | | Occupational Health Law (gpt-oss-120b) | Legal | 49% | +13% (Grade B) | | Gas Flaring Analysis (Gemma 3 1B) | Legal | 52% | +33% (Grade A) | | Oil Spill Analysis (Llama 3.3 70B) | Healthcare | 73% (79% general) | +18.8% (Grade A) | | Desertification Analysis (Llama 3.3 70B) | Healthcare | 73% (77% general) | +31% (Grade A) | 🤗 [WASH](https://huggingface.co/mabera/nigeria-wash-health-model) | 🤗 [Malaria](https://huggingface.co/mabera/nigeria-malaria-health-model) | 🤗 [Poverty](https://huggingface.co/mabera/nigeria-poverty-prediction-model) | 🤗 [Language](https://huggingface.co/mabera/nigeria-multilingual-health-model) | 🤗 [Legal](https://huggingface.co/mabera/africa-environmental-law-model) | 🤗 [Marketing](https://huggingface.co/mabera/africa-development-risk-index-model) | 🤗 [Outbreak](https://huggingface.co/mabera/nigeria-outbreak-analysis-model) | 🤗 [OSH Law](https://huggingface.co/mabera/nigeria-occupational-health-law-model) | 🤗 [Gas Flaring](https://huggingface.co/mabera/nigeria-gas-flaring-analysis-model) | 🤗 [Oil Spill](https://huggingface.co/mabera/nigeria-oil-spill-analysis-model) | 🤗 [Desertification](https://huggingface.co/mabera/nigeria-desertification-analysis-model) | 📊 [Kaggle](https://www.kaggle.com/yunusahusseinadeiza) """) demo.launch()