Using Machine Learning to Find Water Underground in Nigeria
How I automated groundwater prediction using geo-resistivity data and scikit-learn without a single expert geophysicist in the loop
About Me
I am Ade-Onojobi Kehinde, a final-year mechanical engineering undergraduate at Lead City University, Ibadan, and a student fellow with Afara Initiative. I’m an engineer, and I prefer building processes over solving problems in isolation. My interest in this stems from my engineering background, a handful of internships, and living and working in a developing economy where infrastructure gaps make daily life difficult. I like sports (especially the fast-paced and dynamic ones), and I like movies, music, and traveling. Other than that.
This project pulled me in because it sits at the intersection of a real technical problem and a real business case. Groundwater access in basement complex terrain is a genuine engineering bottleneck in Nigeria, and the entrepreneurial angle building something field teams could actually use made it more than an academic exercise.
But the practical deployment in resource-constrained environments, especially in developing economies, remains a tough challenge, even as companies in AI and data science are pushing the boundaries of machine learning into new frontiers. In this article, I walk through a project that tries to bridge exactly this gap: using machine learning to predict where to drill for water in Northern Nigeria’s basement complex geology.
This project is part of my fellowship with the Afara Initiative, a Nigerian professional development initiative.
(The full code & notebooks are available on Github [https://github.com/Dot-kenny/Aquifer-Predictor-Model.git] if you want to follow along
The Problem
Finding groundwater in Nigeria is not as easy as it seems.
Much of the Nigerian hinterland from Ilorin through Ibadan down to Abeokuta sits on what geologists call Precambrian basement complex terrain. These are ancient crystalline rocks: granite, gneiss, and schist. Unlike sedimentary formations, they don’t hold water consistently. Water only exists in pockets where the rock has been fractured or chemically weathered over millions of years.
The consequence? About 40% of boreholes drilled in these areas fail to find water. Each failed borehole wastes money, time, and community trust.
The standard approach involves deploying a specialist geophysicist to conduct and manually interpret Vertical Electrical Sounding (VES) surveys, injecting electrical current into the ground, and measuring how much resistance the earth puts up at increasing depths. A trained expert then reads these resistivity curves and decides whether to drill here or not.
This approach doesn’t scale. There aren’t enough geophysicists. The process is slow, expensive, and subjective.
The question I wanted to answer: Can a machine learning model look at raw VES resistivity numbers and tell us whether a productive aquifer is likely? No expert required.
The Dataset
I used a published dataset from a 2020 journal paper by Raji & Abdulkadir of the University of Ilorin (DOI: 10.1016/j.dib.2020.105975), freely accessible on Mendeley Data.
The dataset contains resistivity measurements at 85 georeferenced survey stations across a 110 km² area of Ilorin, Kwara State. At each station, apparent resistivity was recorded at 24 electrode depth spacings ranging from 1 meter to 100 meters below the surface.
Why not use my own field survey data from Abeokuta and Ibadan? Two reasons. Sample size. Standardization. Precisely what machine learning needs, the University of Ilorin team had already gathered 85 stations using a rigorous, peer-reviewed methodology. My own surveys were too small and too varied in format to train a model on them. And geologically, it doesn’t matter: the subsurface structure in Ilorin, Ibadan, and Abeokuta is essentially the same. A model that works in Ilorin can be replicated all over the Nigerian basement complex.
This is one way to think of it. If you want to teach a model to tell the difference between ripe and unripe mangoes, you don’t have to grow the mangoes yourself. You find a researcher who has already done this in a systematic way. That’s data acquisition in ML.
Data Cleaning
Before any modeling, we ran a full quality audit. Here’s what we found:
Result: zero missing values. That’s a clean starting point.
But two problems surfaced:
Problem 1: Duplicate depth levels: Electrode spacings of 6 m, 10 m, 40 m, and 80 m each appeared twice. We averaged the duplicates and dropped one, reducing features from 24 to 20.
Problem 2: Station naming mismatches: Two stations had different names in the resistivity file versus the coordinates file (VES31.1 vs. VES32 and VES58.1 vs. VES59). Without fixing this, those two stations would have had no GPS coordinates after the merge.
Data cleaning is unglamorous but non-negotiable. A model trained on dirty data doesn’t learn patterns; it learns noise.
Preprocessing Pipeline
With clean data in hand, we ran three transformation steps before touching any model.
Step 1: Log₁₀ Transformation
Raw resistivity values ranged from 6 to 1,768 ohm-meters, with a skewness of 5.0. Most values clustered at the low end, with a long tail of extreme
Why log? Because electrical resistivity in the earth naturally spans orders of magnitude, geophysicists have always plotted resistivity on log scales. We’re just making our data match the physical reality.
Step 2: Standard Scaling
After log transformation, different depth levels still had different numerical ranges. StandardScaler brought every feature to zero mean and unit variance.
Distance-based algorithms like K-means and SVM treat all features on the same linear scale. Without this step, a feature with a range of 50–300 would dominate one with a range of 0.5–3.0 regardless of which is actually more informative.
Step 3: PCA (Dimensionality Reduction)
A correlation check revealed that 95 of the 190 feature pairs had correlations above 0.90. Most depth levels were saying essentially the same thing; that’s redundancy, not information.
Three principal components retained 95.8% of all variance in the original 20 features. Think of it like a 20-instrument orchestra condensed to 3; the music is essentially the same.
The Label Problem
Here’s where it gets interesting. The dataset had no ground-truth labels; no one had recorded whether each station actually produced water when drilled.
Get Adeonojobi kehinde’s stories in your inbox
Join Medium for free to get updates from this writer.
Supervised machine learning requires labels. So we created proxy labels using domain knowledge:
The 150 ohm-meter threshold is supported by published geophysical science: in basement complex terrain, saturated weathered rock has consistently low resistivity, while dry crystalline rock has high resistivity. This is not arbitrary but the same rule geophysicists use manually when reading VES curves.
It’s like grading mangoes by color before having a trained taste tester. If your color rule is physically sound, and this one is, the labels have their uses. Not perfect, but good enough for training a model.
Four Tasks of ML
Task 1: K-Means (Unsupervised Classification)
We let the data sort itself before we even use labels. K-Means with k=3 groups the 85 stations only based on resistivity similarity.
The main result was that the clusters were spatially coherent. Stations in the same cluster were generally physically close to each other, which implies similar underground conditions are found in similar geographic locations. This is independent, unsupervised confirmation that the data has real geological signal, not noise.
Why k=3? Basement complex geology generally has three subsurface conditions, namely, weathered zone, fractured basement, and fresh basement. This choice was not arbitrary.
Task 2: Binary Classification (SVM & Random Forest)
Then, given the proxy labels, we applied supervised classification.
With only 85 samples, a simple train/test split would produce unreliable results. Stratified K-Fold Cross-Validation ensures every station gets tested exactly once, which is essential for small datasets.
Random Forest outperformed SVM. Feature importance analysis showed that the most predictive measurements were mid-depth resistivity levels at 15 m to 45 m AB/2, not the shallowest readings (topsoil) and not the deepest (fresh granite), but exactly the zone where aquifers form in basement complex terrain.
Task 3: Geospatial Prediction (Gaussian Process)
Instead of classifying 85 discrete points, we wanted a continuous probability map over the entire study area of 110 km². Enter the Gaussian Process Classifier.
The model has location awareness from the GPS coordinates. It learns not only what the resistivity looks like at each station but also where similar conditions are likely to extend between measured points.
a color-mapped probability surface of groundwater potential for the entire study area, the kind of map a drilling program manager can actually use.
Task 4: Anomaly Detection using Isolation Forest
Finally, we marked stations that do not fit any expected pattern.
Isolation Forest marks points that are “easy to isolate” as statistically anomalous and far away from the main clusters. Geologically, these are sites with strange resistivity profiles that may indicate dense fracture networks, pegmatite bodies, or just measurement artifacts in the field. Whatever the cause, human follow-up is needed before any drilling decision.
Results Summary
Most predictive features: mid-depth resistivity at 15–45 m AB/2, the zone where aquifers live in basement complex geology. Not shallow, not deep. The middle.
Challenges and How We Handled Them
Every real-world ML project has messy problems that tutorials don’t prepare you for. Here are ours:
What Comes Next
This project demonstrates that ML can meaningfully support groundwater exploration even with a small dataset and no verified labels. But there’s more to do:
- Obtain verified labels from the original dataset authors
- Expand to more locations: Ibadan, Abeokuta, and beyond
- Explore deep learning as the dataset grows
- Deploy as a lightweight inference tool that field teams can use on a laptop, feeding in new VES survey data and getting an aquifer probability score back within seconds
Drilling technology is not the bottleneck for the management of groundwater resources in Sub-Saharan Africa. It is an expert’s ability to choose where to drill. One of the most promising routes to removing that bottleneck entirely is machine learning.
All codes were implemented in Python 3 using scikit-learn, pandas, and NumPy in a Jupyter Notebook environment. The dataset is available publicly on DOI: 10.1016/j.dib.2020.105975.Full project code is available on Github: [https://github.com/Dot-kenny/Aquifer-Predictor-Model.git]
Ade-Onojobi Kehinde is a student fellow of the Afara Initiative Bridge Program (Cohort 2025) and a mechanical engineering undergraduate at Lead City University Ibadan.









