Are you ready to build your first machine learning model in Python? If so, your search ends here. Abuja Data School is Nigeria’s top live AI training centre. This step-by-step guide walks you through the full process from raw data to a working model. Furthermore, every step includes real Python code that you can run today in Google Colab for free. As a result, by the end of this guide, you will easily build your first real ML model.
So, this guide covers the 6-step ML workflow: data loading, exploration, cleaning, model building, evaluation, and saving. Every step uses a Nigerian business context so the work feels relevant. In short, this is not a toy exercise. It is how Nigerian data scientists at Abuja banks, fintechs, and NGOs build ML models every day.

What You Need Before You Start
You need three things:
- Python 3: Install it at python.org or just use Google Colab, which runs Python in your browser with no install needed.
- Key libraries: pandas, scikit-learn, and matplotlib. All are free. In Google Colab, they are already installed.
- Basic Python knowledge: You should know how to write a simple Python script. If you do not, the Abuja Data School Python for AI course covers this.
Also, every code block in this guide can be pasted directly into a Google Colab notebook and run for free. In short, open a Google Colab tab now and follow along as you read.
The 6-Step ML Workflow
| Step | Action | Tool Used | Nigerian Example |
| 1 | Load your data | pandas | Load Abuja loan data from a CSV file |
| 2 | Explore the data (EDA) | pandas, matplotlib | Check data types, missing values, distributions |
| 3 | Clean and prepare the data | pandas, scikit-learn | Fill blanks, encode text columns, split train/test |
| 4 | Choose and train a model | scikit-learn | Train a logistic regression model to predict default |
| 5 | Evaluate the model | scikit-learn metrics | Check accuracy, precision, recall, and confusion matrix |
| 6 | Save and share the model | joblib | Save the trained model file for deployment |
Step 1: Load Your Data
The first step is loading your data into Python using pandas. For this guide, we will use a simplified Nigerian bank loan dataset. In a real Abuja Data School project, this data is stored as a CSV file. Here is how to load it:
import pandas as pd
# Load the loan data
df = pd.read_csv(‘abuja_loans.csv’)
# See the first 5 rows
print(df.head())
print(df.shape) # rows and columns
Also, if you are using a real Abuja bank dataset, never share raw customer data publicly. Always anonymise or use sample data for tutorials. In short, data privacy starts at step one.
Step 2: Explore Your Data (EDA)
Before building any model, explore your data. EDA tells you what you have, what is missing, and what patterns exist. Here are the key checks:
# Check data types and missing values
print(df.info())
print(df.isnull().sum())
# Summary statistics
print(df.describe())
# Check the target column balance
print(df[‘default’].value_counts())
Also, plot a histogram of the loan amount column to see the distribution:
import matplotlib.pyplot as plt
df[‘loan_amount’].hist(bins=30, color=’steelblue’)
plt.title(‘Loan Amount Distribution — Abuja Bank Data’)
plt.xlabel(‘Loan Amount (NGN)’)
plt.ylabel(‘Count’)
plt.show()
In short, EDA is not optional. Skipping it is the single most common reason Nigerian ML models perform poorly in production.
Step 3: Clean and Prepare Your Data
Raw data is never clean. This step handles missing values, encodes categorical columns, and splits the data into training and test sets.
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
# Fill missing numeric values with the column median
df[‘loan_amount’].fillna(df[‘loan_amount’].median(), inplace=True)
df[‘income’].fillna(df[‘income’].median(), inplace=True)
# Encode the employment_type text column
le = LabelEncoder()
df[’employment_type’] = le.fit_transform(df[’employment_type’])
# Define features (X) and target (y)
X = df[[‘loan_amount’, ‘income’, ’employment_type’, ‘loan_term’]]
y = df[‘default’]
# Split: 80% train, 20% test
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, random_state=42
)
Also, set random_state=42 so your results are reproducible. This is a widely used convention in Nigerian and global ML teams. In short, clean data is the single biggest driver of good model performance.
Step 4: Choose and Train a Model
For a first model, logistic regression is the best starting point for a classification problem like loan default prediction. It is fast, interpretable, and gives clear feature importance signals. Here is how to train it:
from sklearn.linear_model import LogisticRegression
# Create the model
model = LogisticRegression(max_iter=1000)
# Train it on the training data
model.fit(X_train, y_train)
print(‘Model trained successfully!’)
In short, those three lines create, fit, and done are the core of every supervised ML model in scikit-learn. The syntax is the same whether you use logistic regression, random forest, or XGBoost.
Step 5: Evaluate Your Model
A model is only as good as its performance on data it has not seen. Evaluate on the test set, not the training set:
from sklearn.metrics import (accuracy_score, classification_report,
confusion_matrix)
# Make predictions on the test set
y_pred = model.predict(X_test)
# Print key metrics
print(‘Accuracy:’, accuracy_score(y_test, y_pred))
print(‘\nClassification Report:’)
print(classification_report(y_test, y_pred))
print(‘\nConfusion Matrix:’)
print(confusion_matrix(y_test, y_pred))
Also, do not rely on accuracy alone for imbalanced Nigerian data sets. A model that labels every loan as “not default” could score 95% accuracy on a data set where only 5% of loans default. In short, always check precision, recall, and the confusion matrix.
Step 6: Save Your Model
Once you are happy with performance, save the trained model so it can be deployed or shared:
import joblib
# Save the model
joblibdump(model, ‘abuja_loan_default_model.pkl’)
# Load it back later
loaded_model = joblib.load(‘abuja_loan_default_model.pkl’)
# Make a prediction with the loaded model
print(loaded_model.predict([[500000, 200000, 1, 12]]))
In short, saving your model with joblib is how a trained ML model moves from your notebook into a real Nigerian bank or fintech system.
Free Resource: scikit-learn Official Documentation
In addition to Abuja Data School’s live training, Abuja Data School recommends the scikit-learn official documentation as the best free reference for every Python ML tool used in this guide. The scikit-learn docs include clear examples, tutorials, and a user guide for every model, metric, and preprocessing tool. Also, the getting-started guide is beginner-friendly and works well for Nigerian learners at any Python level. Moreover, all examples can be run in Google Colab at no cost. As a result, any Nigerian who works through this guide alongside the scikit-learn docs will have a solid, working understanding of Python ML from the ground up.
The scikit-learn docs serve as your reference. Use Abuja Data School’s live courses to build the full ML skill with real Nigerian data sets, live instruction, and a career-linked portfolio. Together, they are the fastest path to a working Nigerian ML engineer skill.
What to Do After Your First Model
Abuja Data School encourages every first-model builder to take these next steps:
- Push your notebook to GitHub: This is your first ML portfolio project. Paste the code into a Jupyter notebook, add comments to each step, and push it to a public GitHub repo. Nigerian employers and global remote clients check GitHub.
- Try a different model: Replace Logistic Regression with Random Forest Classifier and compare the results. One line of code change. Same workflow.
- Use a Nigerian data set: Replace the sample data with a real Nigerian data set from Kaggle or a public Nigerian government data portal. The same six steps apply.
- Join an Abuja Data School live course: The ML Foundations course takes this six-step workflow much further: cross-validation, feature engineering, hyperparameter tuning, and full project deployment.
To enrol, visit the Abuja Data School Data Analysis page.
Frequently Asked Questions: First ML Model in Python
Q1: Can I Run This Code for Free?
Yes. Google Colab gives you free Python with all the key ML libraries pre-installed. Open colab.research.google.com, start a new notebook, and paste the code from this guide. No install needed. Also, Google Colab provides free GPU access for deeper models. In short, your first ML model costs nothing to build.
Q2: What Data Set Should I Use for My First Model?
Start with a simple, clean data set. The UCI Machine Learning Repository and Kaggle both have good starter data sets. Also, look for Nigerian data sets on Kaggle or the Nigeria Open Data portal. In short, use a data set where you understand the business problem; loan default, churn, or disease risk are all strong Nigerian first-model choices.
Q3: How Accurate Should My First Model Be?
Do not expect 99% accuracy from your first model. A logistic regression model on a well-cleaned data set is often scored at 75% to 85% accuracy. That is a strong result for a first model. Also, focus on understanding the evaluation metrics, not just the accuracy number. In short, a 78% model you fully understand is far more valuable than a 95% model you cannot explain.
Your First Model Is One Paste Away. Keep Building at Abuja Data School
Ultimately, the six steps in this guide are the same steps used by every Nigerian ML engineer working at a bank, fintech, or NGO today. The only difference between you and them is practice. So run the code. Build the model. Push it to GitHub. Then come back and do it again with a harder problem.
To that end, take your next step today. Visit the Abuja Data School Data Analysis page and enrol in the ML Foundations course. As a result, your first GitHub ML portfolio, your first ML role, and your highest-ever Nigerian salary are just one enrolment at Abuja Data School away.

