## glossary
What is Machine Learning?
Machine Learning is the field of artificial intelligence in which systems improve their performance on a task through exposure to data, without the rules being explicitly programmed. Instead of writing the logic, you provide examples and let the algorithm infer the patterns.
The difference becomes clear with a concrete case. To detect spam with traditional programming, someone would need to write hundreds of rules and maintain them as spammers change tactics. With machine learning, you provide thousands of labeled emails and the model figures out on its own which signals matter.
The three types of learning
- Supervised — trains on labeled data, where the correct answer is known. Used in classification (spam or not) and regression (predicting a price).
- Unsupervised — receives unlabeled data and looks for structure on its own: customer clusters, anomaly detection, dimensionality reduction.
- Reinforcement — the agent learns by trial and error, receiving rewards or penalties. The foundation of systems that play games, control robots and optimize operations.
The workflow of a real project
The part that surprises newcomers: the algorithm is the smallest slice of the work. Most of the effort goes into collecting, cleaning and preparing data.
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import classification_report
# split train and test BEFORE any fitting
X_treino, X_teste, y_treino, y_teste = train_test_split(
X, y, test_size=0.2, random_state=42, stratify=y
)
modelo = RandomForestClassifier(n_estimators=200, random_state=42)
modelo.fit(X_treino, y_treino)
# always evaluate on data the model has never seen
print(classification_report(y_teste, modelo.predict(X_teste)))That train/test split is not a formality. Evaluating a model on the very data it was trained on produces excellent — and completely misleading — numbers. It is the most common mistake among beginners.
Metrics: accuracy is rarely enough
If 99% of emails are not spam, a model that always answers "not spam" is right 99% of the time and is useless. That is why practitioners use precision (of the ones I flagged as positive, how many actually were), recall (of the real positives, how many I found) and F1, which balances the two. The choice depends on the cost of the error: in medical diagnosis, missing a case is far worse than a false alarm.
Limitations that matter
Models learn correlation, not causation — and they reproduce the biases present in the training data, sometimes amplifying them. They also degrade over time as reality changes and production data drifts away from the training data, a phenomenon called data drift. And there is the risk of overfitting, when the model memorizes instead of generalizing. To go deeper, see machine learning fundamentals and how to build machine learning projects.
## faq
Frequently asked questions
What is the difference between AI, Machine Learning and Deep Learning?
They are nested layers. Artificial Intelligence is the broad field of making machines perform tasks that would require intelligence. Machine Learning is the subset where this is done by learning from data. Deep Learning is a subset of ML that uses deep neural networks, dominant in image, audio and language.
Do I need a lot of math to work with ML?
To use off-the-shelf libraries on common problems, basic linear algebra and statistics are enough. To understand why a model fails, tune architectures or do research, calculus, probability and optimization become genuinely necessary.
How much data is needed to train a model?
It depends on the complexity of the problem and the model. Classical algorithms can work with a few thousand well-labeled examples. Deep networks usually demand much more — although transfer learning makes it possible to adapt pre-trained models with small datasets.
## read next