Machine learning flashcards
Teach computers to learn patterns from data.
Beginner friendly, starts from zero
0
Machine learning at a glance
Machine learning teaches a computer to make good guesses by showing it many examples instead of writing every rule.
It is like a child learning fruit names: after seeing many named apples and bananas, he can name a new fruit with no rule book.
Words you will meet
- Data
- Recorded facts, usually a table of rows and columns
- Feature
- A detail you already know about an example, like a house's area
- Label
- The answer you want the computer to guess, like the price
- Model
- A formula with numbers the computer tunes from examples
- Training
- Letting the model guess, check its errors and adjust, many times
- Prediction
- The model's guess for a new example
- Test set
- Examples hidden during training, used to check the model fairly
- Accuracy
- The share of test answers the model got right
The steps
- 1. Start from zero (12 cards): What learning from examples means, the key words, and a model in three lines.
- 2. Core basics (16 cards): What ML is, features and labels, splits, your first model and data quality.
- 3. Next steps (16 cards): Loss, metrics, cross-validation, tuning, trees and pipelines.
- 4. Go deeper (16 cards): Leakage, imbalance, calibration, drift, fairness and shipping models.
All 12 cards in Start from zero
- What is machine learning, in one plain sentence?
- Teaching a computer by showing it many examples, instead of writing every rule by hand, so it can make good guesses about new cases.
- What problem does it solve that normal programs could not?
- Some jobs have too many rules to write, like spotting spam or reading handwriting. People wrote rule after rule, and the rules kept breaking as the world changed.
- Where do you already use machine learning every day?
- Spam filters, phone face unlock, video suggestions, map arrival times and the next-word hints on your phone keyboard all come from machine learning.
- What is an everyday picture of how a machine learns?
- A child sees many apples and bananas, each named by a parent. Soon he names a fruit he has never seen. Nobody gave him a rule list; he learned the pattern.
- What are data, rows and columns?
- Data is recorded facts, usually kept in a table. Each row is one example, such as one house, and each column is one detail about it, such as its area or city.
- What are features and a label?
- Features are the details you already know, like a house's area and city. The label is the answer you want the computer to guess, like the house price.
- What are a model, its parameters and a prediction?
- A model is a formula the computer builds from examples. Its parameters are the numbers inside it that get tuned. A prediction is the model's guess for a new example.
- What happens during training, and what is loss?
- Training means the model guesses on examples, measures how wrong it was (the loss, a wrongness score), and adjusts its numbers to be a little less wrong. This repeats many times.
- What are a test set and accuracy?
- You hide some examples during training, like keeping back exam questions. The test set checks the model on them, and accuracy is the share of answers it got right.
- Your first tiny win: what does this little model print?
- 55.0, meaning 55 lakh rupees. The parameters are 0.04 and 15, the feature is the area, and the printed prediction is the price. Training is just finding good numbers like these.
- What do you need before starting this topic?
- For the ideas, nothing at all. For the code cards, basic Python helps, and you can run it in any free online Python notebook in your browser.
- What will you be able to do after this topic?
- Turn a real question into a machine learning task, prepare the data, train and test a first model in Python, and tell whether its score is truly good.
Machine learning cheatsheet
scikit-learn core
model.fit(X, y)Learn from training datamodel.predict(X)Labels or valuesmodel.predict_proba(X)[:, 1]Positive-class probabilitytrain_test_split(..., stratify=y)Keep class mix in both setscross_val_score(pipe, X, y, cv=5)Five-fold scoresmake_pipeline(prep, model)Preprocessing and model as one objectColumnTransformer([...])Per-column preprocessing
Metrics
precisionTP / (TP + FP): are alerts right?recallTP / (TP + FN): did we catch them?F1Harmonic mean of precision and recallPR AUCRare-class ranking qualityROC AUCOverall ranking, flattering when imbalancedRMSE / MAERegression error; RMSE punishes big missesBrier scoreProbability calibration
Pick a model
Tabular, any sizeHistGradientBoosting, LightGBM, XGBoostNeed explanationsLogistic regression or a shallow treeSmall, clean baselineLogistic or linear regressionImages, text, audioFine-tune a pretrained neural netGroups, no labelsk-means or HDBSCANRare anomaliesIsolationForest
Split strategies
StratifiedKFoldClassification, keep class ratiosTimeSeriesSplitPast to train, future to validateGroupKFoldSame patient or user stays in one foldHold-out testTouched once, at the end
Symptom and fix
Train high, test lowRegularise, simplify, more dataBoth lowBetter features, more flexible modelToo-good scoreHunt for leakageRare class ignoredclass_weight, PR AUC, tune thresholdProbabilities offCalibratedClassifierCVLive accuracy fallsCheck drift, retrain on recent data