from pathlib import Path src = Path("/mnt/data/Pasted text(20260812-001923).txt") original = src.read_text(encoding="utf-8") # Build a complete replacement HTML page. This keeps the user's current structure/branding # while expanding it into an interactive, job-ready Machine Learning clubhouse. html = r''' Kodi's Code Clubhouse — Machine Learning Practitioner Lab
🤖

Kodi's Code Clubhouse

Machine Learning — from pattern hunter to job-ready creator

A Koinder Global Limited production

🧠 Machine Learning: Rules Learned, Not Written

First understand why machine learning had to exist. Then touch the ideas, break them, fix them, code them, and finally ship something that works.

Module 4 · Practitioner Track · 18+ · Creator Lab
👁️ See it🗣️ Say it🧠 Think it

🎯 The Kodi Creator Loop

SEE → GUESS → WHY → DISCOVER → TOUCH → BREAK → FIX → CODE → BUILD → EXPLAIN → SHIP

Do not rush to algorithms. A working practitioner first learns to recognise a problem, frame it, question the data, measure failure, and explain what the model is doing.

Room 1 · Why Did Machine Learning Need to Exist?

Before Python. Before models. Before formulas. Start with the problem humans were trying to solve.

🧠 Think first✋ Choose

🏦 2,000,000 Loan Applications Arrive Tomorrow

Yesterday your bank received 10 loan applications. Tomorrow it expects 2,000,000. For every applicant you must decide: LIKELY TO REPAY or LIKELY TO DEFAULT.

You have only seconds per application. What would you do?

Normal Programming Works When the Rule Is Known

RULES + DATA → ANSWERS
Price = ₦1,000
+
Quantity = 5
Rule: price × quantity
₦5,000

If a rule is clear, stable and easy to write, ordinary programming may be the better tool.

🎮 Playground🧠 Discover

Playground 1 · You Are the Spam Programmer

Classify each message. Then Kodi will challenge the rule you think you used.

🔄 The Big Inversion

Traditional programming: RULES + DATA → ANSWERS
Supervised machine learning: DATA + KNOWN ANSWERS → LEARNED MODEL
Examples
+
Known outcomes
Learning algorithm
Learned model
New prediction

Kodi: “Beautiful. But I simplified it. That shape mainly describes supervised learning. What happens when nobody has supplied the answers?”

Room 2 · The Dream of a Machine That Learns

History is useful when it explains why the next idea appeared.

👁️ See it👂 Hear it

📖 The Dream of Seven Cows

Pharaoh, the king of Egypt, woke up frightened. He had seen seven healthy cows followed by seven thin cows, and the thin cows ate the healthy ones.

Joseph interpreted the pattern as seven years of plenty followed by seven years of famine. Egypt acted on the prediction and stored grain.

Joseph did not create the future. He read a pattern and acted on it.— Genesis 41

🧠 From Pattern Recognition to Learning Machines

1940s
Researchers explored simplified mathematical models inspired by biological neurons: inputs come in, signals are combined, an output comes out.
1950
Alan Turing publicly pushed the question of machine intelligence: how might we judge intelligent behaviour in a machine?
1950s
Early trainable systems such as the perceptron made the idea concrete: a machine could adjust parameters from examples.
1959
Arthur Samuel popularised the term machine learning while developing checkers-playing programs that improved through experience.
Later
More data, more computing power and improved optimisation made increasingly complex models practical.
🎮 Playground👁️ See the score

Playground 2 · Build a Tiny Artificial Neuron

This is not a biological brain. It is a mathematical toy that receives signals, combines them and decides whether a threshold has been reached.

Σ signals
0
Threshold = 5
OUTPUT: NO

Playground 3 · Learn by Reward

Kodi can choose A, B or C. Each action gives a different reward. Run experience repeatedly and watch which action becomes attractive.

A: +2chosen 0 times
B: -1chosen 0 times
C: +5chosen 0 times

Room 3 · Should This Even Be Machine Learning?

Professionals are paid to solve the problem, not to put AI everywhere.

Playground 4 · ML or Not?

🧭 The Practitioner Question

Before training anything, ask:

1

Is there a decision or prediction that matters?

2

Do we have enough relevant examples or signals?

3

Would a simple rule, query or formula solve it more reliably?

4

What happens when the model is wrong?

Room 4 · Turn Business Language Into an ML Problem

💼 Your Manager Says: “Customers Are Disappearing.”

Your job is not to immediately choose Random Forest. Translate the complaint into something measurable.

Business painCustomers are disappearing
DecisionWho should retention contact?
PredictionWho may stop buying?
TargetChurn = yes/no
FeaturesBehaviour before prediction time
ActionRetention intervention

Playground 5 · ML Project Canvas

Fill this before modelling. This is the thinking companies actually need.

Room 5 · Supervised, Unsupervised and Reinforcement Learning

SUPERVISED

You already have answers

Examples: default/repaid, spam/not spam, house prices, disease labels.

Question: learn a relationship that predicts an outcome.

UNSUPERVISED

No answer labels

Examples: customer groups, strange transactions, product relationships.

Question: what structure is hiding in the data?

REINFORCEMENT

Actions produce rewards

Examples: game playing, control systems, simulated robotics.

Question: which actions lead to better long-term outcomes?

Playground 6 · Classification or Regression?

Room 6 · Features, Targets and Leakage

Loan Application Anatomy

FieldValueRole
Age32Feature
Monthly income₦420,000Feature
Existing debt₦70,000Feature
Employment years6Feature
Previous late payments0Feature
Defaulted?NoTarget

Playground 7 · Spot the Leakage

A loan-default model uses the following fields. Click anything that would not legitimately be known at prediction time.

Room 7 · Dirty Data Is the Real Job

⚠️ The Part Course Adverts Rarely Show

There is no universal percentage split for an ML project. But real practitioners often spend substantial time acquiring, cleaning, understanding and shaping data, evaluating failures, deploying systems and monitoring them. Model training may be the short part.

Playground 8 · Data Detective

Click suspicious cells. Find as many data-quality problems as you can before training anything.

CustomerStateSalesDate
AmakaLagos₦5,00012/4/26
AMAKAlagos500012-04-2026
EmekaLAGN/AApril 12
JohnAbuja₦-90014/04/26
 ABUJA7,300 
Tundeabjseven thousand 
TundeAbuja700014/04/26
0 suspicious cells found

Room 8 · Feature Engineering — Teach the Machine What to Notice

Raw Transactions Are Not Always the Final Features

150 transaction rows
Group by customer
Purchases = 17
Avg spend = ₦8,420
Days since last = 51

Feature engineering turns raw records into useful signals aligned with the prediction moment.

Playground 9 · Feature Factory

Customer 77 has these transactions:

DateAmount
2026-01-02₦4,300
2026-01-18₦12,000
2026-02-01₦2,500
2026-04-09₦7,600

Room 9 · Training, Validation, Testing and Overfitting

Training setquestions you study with
Validation setpractice exam
Test setunseen final exam

If you let the model see the final examination during training, the score no longer tells you how well it handles new data.

Playground 10 · The Cheating Model

88%Training performance
86%Test performance

Baseline First: Beat Something Simple

If 81% of customers stay, a model that predicts STAY for everyone already gets 81% accuracy. Your expensive model should prove it adds useful value beyond that.

Room 10 · Accuracy Can Lie

💳 Fraud Detector With 99.9% Accuracy

Suppose only 1 transaction in 1,000 is fraud. A system that calls every transaction “legitimate” can be 99.9% accurate while catching zero fraud.

That is why practitioners choose metrics based on the consequences of mistakes.

Playground 11 · Confusion Matrix

Actual Fraud
Actual Normal
Predict Fraud
7
True Positive
8
False Positive
Predict Normal
3
False Negative
82
True Negative
70%Recall = 7 / 10 real fraud caught
46.7%Precision = 7 / 15 accusations correct

Playground 12 · Move the Fraud Threshold

82%Recall
61%Precision
14%False alarm rate

Room 11 · The Algorithm Garage

Now the learner is ready to meet models — as tools chosen for reasons, not names to memorise.

REGRESSION

Linear Regression

Why: predict a numerical quantity with a simple relationship.

Watch: outliers, nonlinearity, assumptions.

CLASSIFICATION

Logistic Regression

Why: estimate probability of categories such as default/no default.

Watch: feature scale, linear decision shape.

TREE

Decision Tree

Why: learn understandable branching decisions.

Watch: deep trees overfit easily.

ENSEMBLE

Random Forest

Why: many varied trees vote, often improving robustness.

Watch: heavier models, less direct interpretability.

BOOSTING

Gradient Boosting

Why: sequential models focus on correcting earlier mistakes.

Watch: tuning, leakage, overfitting.

NEIGHBOURS

K-Nearest Neighbours

Why: predict using similar nearby examples.

Watch: scaling and slow prediction on large datasets.

PROBABILITY

Naive Bayes

Why: simple probabilistic evidence, often useful for text.

Watch: independence assumptions.

CLUSTERING

K-Means

Why: discover groups when labels do not exist.

Watch: scale, number of clusters, interpretation.

DEEP LEARNING

Neural Network

Why: learn layered representations for complex patterns.

Watch: data needs, compute, tuning, interpretability.

Playground 13 · Move the Decision Boundary

Drag the slider. Your line tries to separate blue examples from orange examples.

Playground 14 · Random Forest Voting

Ask 12 small decision trees to vote on the same customer.

Room 12 · Unsupervised Learning — Discover Structure

Playground 15 · Discover Customer Segments

No one labelled these customers. Choose how many groups you want Kodi to look for, then inspect the resulting descriptions.

Room 13 · Reinforcement Learning and Reward Hacking

STATE → ACTION → ENVIRONMENT → REWARD → NEW STATE → repeat

Playground 16 · Design the Robot Reward

Your cleaning robot receives points. Change the reward design and see whether it creates the behaviour you intended.

Room 14 · Bias, Fairness and Responsible ML

Historical Data Is Not Automatically Fair Data

A model can learn patterns from past decisions, including undesirable patterns. “The computer learned it” does not automatically make the output acceptable.

Historical data
Learned patterns
Decisions at scale

Practitioners inspect how errors and outcomes differ across relevant populations, review whether features are legitimate, and ensure humans understand the risks of automated decisions.

Room 15 · Distribution Shift — Reality Changed

⛽ Yesterday's World Is Not Guaranteed Tomorrow

A demand model can be perfectly implemented and still deteriorate if prices, regulations, consumer behaviour, seasons or economic conditions change. The model is a claim that patterns in past data remain useful in the current world.

Playground 17 · Break the World

92%Current model performance
LowDrift risk

Room 16 · Deployment — A Model Is Not Yet a Product

🚀 Production ML Pipeline

Raw data
Validation
Cleaning
Feature pipeline
Model
API
Application
Business action
Outcome
Monitoring
Retraining

model.fit() is a milestone. It is not the end of the system.

💼 What an ML Engineer May Actually Do on Tuesday

1

Chase a missing export from another department.

2

Discover three date formats and decide how to standardise them.

3

Explain that a requested feature requires data nobody currently collects.

4

Explain why “99% accuracy” may be bad news.

5

Check whether last month's model still works on this month's world.

6

Occasionally train another model.

Room 17 · MLOps — Make It Survive

Git & Code Versioning

Which exact code created this result?

Data Versioning

Which data snapshot trained this model?

Experiment Tracking

Which parameters, metrics and model version won?

API / Serving

How does another application request predictions?

Containers

How do we make the environment reproducible?

Monitoring

Is input data, latency or model quality changing?

Retraining

When do we teach the model from newer reality?

Rollback

What if the new model is worse in production?

Room 18 · Python and Tooling Roadmap

Pythonlanguage
Jupyterexperiments
NumPynumerical arrays
Pandasdata wrangling
Matplotlibvisual inspection
scikit-learnclassical ML
SQLretrieve data
Gitversion work
FastAPIserve predictions
Dockerpackage runtime

Later: PyTorch, TensorFlow/Keras where appropriate, XGBoost/LightGBM/CatBoost, experiment tracking and model monitoring.

Room 19 · Kodi's “Why?” Learning Controls

Use the Same Concept From Multiple Angles

Room 20 · Practice Until It Is Yours

🪜 One Small Change Ladder

The idea stays the same while one detail changes. This forces flexible understanding rather than memorising a sentence.

Rung 1 · predict a category

Will this transaction be fraud or legitimate?

Rung 2 · one change: output becomes an amount

How much will this customer spend next month?

Rung 3 · one change: a suspicious feature appears

A churn model includes the customer's future cancellation date. What is wrong?

Rung 4 · one change: train and test disagree

Training accuracy is 99.8%; test accuracy is 64%. What should you suspect?

Rung 5 · one change: fraud is rare

Which metric directly asks “of the real fraud, how much did we catch?”

Room 21 · Teach It Back

🎤 Explain Data Leakage Three Ways

Room 22 · Creator Project Ladder

1. Spam Detector

Classification, text features, precision, recall.

2. Nigerian House Price Predictor

Regression, cleaning, missing values, MAE/RMSE.

3. Cassava Disease Classifier

Images, labels, validation, imbalance.

4. KoMart Segmentation

Clustering, business interpretation.

5. Fraud Detection

Imbalance, thresholds, business cost.

6. Churn System

SQL, features, classification, API, monitoring.

7. Demand Forecasting

Time, seasonality, distribution shift.

8. Recommendation Engine

Similarity and ranking.

9. Document Intelligence

Text classification, embeddings, modern NLP.

10. Production ML Service

Data → pipeline → model → API → app → monitoring.

Room 23 · Modern AI Mental Map

Artificial Intelligence
Machine Learning
Neural Networks
Deep Learning
Transformers
LLMs / Vision / Modern AI Apps

Modern AI becomes much less mysterious when the learner can see how today's systems grew from older ideas.

Final Mission · Save KoMart

🏢 Capstone Brief

KoMart gives you 150,000 transactions. Customer IDs are missing in places. Product names disagree. There are duplicates, refunds, strange dates, promotions and customers with only one purchase.

Mission: identify customers at risk of disappearing so the retention team can act before they leave.

Creator Completion Checklist

🏆 What “Job-Ready” Means Here

The learner should be able to say:

I can frame an ML problem. I can tell when not to use ML. I can clean messy data. I can create features. I can detect obvious leakage. I understand imbalance. I can compare models. I can choose meaningful metrics. I can deploy a prediction service. I can monitor it. I can explain what I built and what could make it fail.

''' out = Path("/mnt/data/kodi_machine_learning_practitioner_lab.html") out.write_text(html, encoding="utf-8") print(f"Created: {out}") print(f"Lines: {len(html.splitlines())}") print(f"Size: {out.stat().st_size/1024:.1f} KB")