Machine Learning Basics: Build Your First Prediction Model
You build one model from the first lesson to the last: it reads a sample table of 7,043 phone company customers, published by IBM, and predicts who will leave. Each lesson adds one working step: split the data, train a first decision tree, measure it with more than accuracy, catch it memorising, cross-validate, add logistic regression, prepare text and blank values in a pipeline, try gradient boosting, test once and explain it. You need basic Python; the few pandas calls used are explained as they appear.
What this course covers
- Turn a Customer Table into a Prediction Question: Explain what a machine learning model learns from a table of past examples, and name the features, the label and the share of each answer in a table loaded with pandas.
- Hold Out Data the Model Never Sees: Split a table into training, validation and test parts that keep the same share of each answer and come out the same on every run, and explain what each part is for.
- Train a First Model: a Small Decision Tree: Train a small decision tree with fit and predict, read the questions it learned, and judge its accuracy against a baseline that always gives the most common answer.
- Measure What Accuracy Hides: Read a confusion matrix, compute precision and recall from it, and explain why accuracy alone flatters a model when one answer is rare.
- Spot Overfitting: Detect overfitting by comparing a model's score on its training rows with its score on validation rows as the model is allowed to grow, and name underfitting at the other end.
- Choose a Setting with Cross-Validation: Score a model with k-fold cross-validation, read the mean and spread of the fold scores, and use them to choose a setting without touching the test set.
- A Second Model: Logistic Regression: Train a logistic regression, explain how it turns a weighted sum of the features into a probability, and read the weights it learned and the probability it gives each row.
- Prepare Features: Text Categories and Blank Values: Turn text categories into numbers with one-hot encoding, find and fill missing values from the reason they are missing, and show what a model gains from the columns it could not use before.
- Scaling and Pipelines: Preparation That Stays Honest: Standardize features so that logistic regression trains properly, join preparation and model into one pipeline, and explain how that keeps held-out rows out of the preparation.
- Gradient Boosting: Does a Stronger Model Win?: Train a gradient boosting model, explain how it builds many small trees one after another, compare it fairly with the simpler models, and choose between models whose scores are close.
- The Final Test: One Honest Number: Refit the chosen model on every row that is not test data, measure it once on the test set, and judge whether the result agrees with what cross-validation promised.
- Explain the Model in Plain Words: Measure which features a trained model relies on with permutation importance, put the result in plain words, and say what such an explanation cannot claim.