Machine Learning Basics
Machine Learning Basics Reference
A one-page reference for ML fundamentals: the workflow, types of learning, common algorithms, evaluation basics, and when not to use ML.
machine learningreference
The workflow at a glance
Every machine learning project follows the same basic loop:
- Data — collect examples of the thing you want to predict, and clean them up. This step usually takes the most time.
- Train — feed the examples to a learning algorithm, which adjusts a model until its predictions on the training data improve.
- Evaluate — test the model on examples it has never seen. Performance on new data is the only score that matters.
- Deploy — put the model to work in a real product or process, then keep monitoring it, because real-world data drifts over time.
If evaluation results are poor, you loop back: get better data, try a different algorithm, or tune settings. For the full story in plain language, read Machine Learning in Plain English.
Types of learning
- Supervised learning — the data comes with answers (labels). The model learns to map inputs to those answers. Examples: spam filtering, price prediction.
- Unsupervised learning — no labels; the model finds structure on its own. Examples: grouping similar customers, spotting unusual transactions.
- Reinforcement learning — the model learns by trial and error, getting rewards for good moves. Examples: game-playing systems, robotics control.
Within supervised learning, two flavors dominate: classification (pick a category: spam or not spam) and regression (predict a number: tomorrow's demand).
Common algorithms and what they're for
- Linear regression — fits a straight-line relationship to predict a number. Simple, fast, easy to explain.
- Logistic regression — despite the name, a go-to method for yes/no classification, like "will this customer churn?"
- Decision trees — a flowchart of if-then questions learned from data. Very easy to read and explain.
- Random forests — many decision trees voting together. A strong, low-fuss default for tabular data.
- Gradient-boosted trees — trees built one after another, each correcting the last one's mistakes. Often the top performer on spreadsheet-style data.
- K-means clustering — an unsupervised method that sorts data into a chosen number of groups.
- Neural networks — layered models that shine on images, audio, and text, where simpler methods struggle.
Evaluation basics
- Accuracy — the share of predictions that were correct. Intuitive, but misleading when one outcome is rare: a model that always says "no fraud" can be 99 percent accurate and useless.
- Precision — of everything the model flagged, how much was actually right? High precision means few false alarms.
- Recall — of everything it should have flagged, how much did it catch? High recall means few misses.
- The trade-off — pushing precision up usually pulls recall down, and vice versa. Which matters more depends on the cost of a false alarm versus a miss.
- Train/test split — always hold back a portion of data the model never trains on, and judge it there. A model graded on its own training data is grading its own homework.
When NOT to use machine learning
- The rules are simple and known. If "flag orders over 500 units" solves it, write that rule instead.
- You have very little data. Models learn from examples; a handful is not enough.
- You need every decision fully explainable. Some regulated decisions require reasoning a complex model cannot provide.
- Mistakes are unacceptable and unrecoverable. ML is probabilistic; it will sometimes be wrong.
- The pattern keeps changing faster than you can retrain. A model trained on yesterday's world decays quickly.
Keep learning
Pair this page with the Machine Learning Terms Cheat Sheet for vocabulary, or step back to What Is Machine Learning? for the concepts behind the workflow.