The ML Landscape with Python
Expert · 18 min read · ▶ live playground · ✦ checkpoint
AI can look like magic from the outside: text appears, images are labeled, prices are predicted, and apps seem to "understand" a question. The useful version is less mystical: machine learning (ML) is a way to make programs learn patterns from examples, and Python gives you the table tools, experiment tools, and modeling libraries that make that workflow practical.
Sort the vocabulary first
Artificial intelligence (AI) is the broad idea of making computers perform tasks that seem to require human judgment: planning, recognizing speech, ranking search results, describing images, writing text, or choosing an action. AI is the umbrella.
Machine learning sits under that umbrella. Instead of writing every rule by hand, you give the program examples and let it find a pattern. A spam filter is a classic example: you do not write a thousand if statements for every possible scam phrase. You show many labeled emails, and the system learns signals that help separate spam from not-spam.
Deep learning is a family of machine-learning methods that use layered neural networks. A neural network is a model built from many small adjustable parts arranged in layers. Deep learning powers many modern image, audio, and language systems, but it is not the whole field. A tiny table and a clean question are still enough for many useful ML problems.
Think of the landscape like a workshop. AI is the whole workshop. Machine learning is the shelf of tools that learn from examples. Deep learning is the heavy machinery on that shelf: powerful, useful, and not always the first thing you reach for.
Rows, features, and labels
Most beginner ML work starts with a table. An example is one observed case, usually one row. A feature is an input column the model may use. A label, also called a target, is the answer column you want the model to learn to predict.
Here is a tiny supervised-learning table written with lists and dictionaries:
rows = [
{"learner": "Mina", "practice_minutes": 25, "slept_well": False, "passed": False},
{"learner": "Ravi", "practice_minutes": 40, "slept_well": True, "passed": False},
{"learner": "Noor", "practice_minutes": 55, "slept_well": True, "passed": True},
{"learner": "Isha", "practice_minutes": 70, "slept_well": False, "passed": True},
]
features = ["practice_minutes", "slept_well"]
label = "passed"
for row in rows:
feature_values = {name: row[name] for name in features}
print(row["learner"], "features =", feature_values, "label =", row[label])Mina features = {'practice_minutes': 25, 'slept_well': False} label = FalseRavi features = {'practice_minutes': 40, 'slept_well': True} label = FalseNoor features = {'practice_minutes': 55, 'slept_well': True} label = TrueIsha features = {'practice_minutes': 70, 'slept_well': False} label = True
The learner's name is useful for reading the table, but it is not a useful feature here. The model should learn from practice and sleep, not memorize names. That distinction matters more than it looks.
Training is the process of fitting a model to examples. A model is the learned pattern or rule that turns features into a prediction. Inference, also called prediction, is using the trained model on a new row.
Supervised, unsupervised, classification, regression
Supervised learning uses examples that already have labels. "Here are house features and their sale prices." "Here are messages and whether they were spam." The label acts like an answer key during training.
Unsupervised learning uses examples without answer labels. Instead of predicting a target, it looks for structure: groups of similar customers, unusual rows, or compressed patterns. You might give it snack purchases and ask, "Which habits seem to cluster together?" No one supplied a correct cluster label up front.
Two supervised tasks come up constantly:
- Classification predicts a category, such as
spamvsnot spam,passedvsdid not pass, orsmall/medium/large. - Regression predicts a number, such as a price, delivery time, temperature, or expected score.
The word regression sounds advanced, but the question is simple: "Am I predicting a category or a number?" That one question often tells you what kind of model and evaluation you need.
Try it - evaluate a rule baseline
A baseline is a simple first approach you compare against. It may be a hand-written rule, an average, or "always choose the most common class." A real model should beat the baseline enough to justify its extra complexity.
This playground searches a few practice-minute thresholds on training rows, picks the best one, and then evaluates it on separate test rows. Change the candidate thresholds or the rows and rerun.
This is not scikit-learn yet. It is a small version of the workflow: choose features, train or choose a rule using training data, predict on new rows, and measure how well the predictions match reality.
Train data, test data, and honest evaluation
A train/test split divides examples into two groups: training data for learning patterns, and test data for checking whether those patterns work on rows the model did not learn from. The split protects you from grading the model on the same rows it studied.
Evaluation is the habit of asking, "How will I know whether this model is useful?" Accuracy can work for some classification tasks, but it is not always enough. A medical screen, a fraud detector, and a movie recommender all care about different mistakes. The metric must match the cost of being wrong.
Two beginner traps show up early:
Overfitting means the model learns the training examples too closely and fails on new examples. A student who memorizes the exact practice quiz can score perfectly on that quiz and still struggle on the real test. Models can do the same thing.
Leakage means information from the answer sneaks into the features. If you predict whether a learner passed and include a feature named certificate_sent, you may have leaked the result, because certificates are sent after passing. Leakage can make test scores look wonderful while the real system fails.
Where Python fits
Python is popular in ML because the ecosystem forms a clean pipeline. You already met parts of that pipeline in the data workflow.
- NumPy handles fast numeric arrays and math under many tools.
- pandas loads, cleans, and reshapes tables before modeling.
- scikit-learn provides classic ML tools for splitting data, training models, predicting, and evaluating.
- Jupyter notebooks help you mix code, output, charts, and notes while exploring.
- PyTorch and TensorFlow are deep-learning frameworks used when you need neural networks and more control over training.
The tool choice depends on the question. A clean table with hundreds or thousands of rows often starts with pandas and scikit-learn. A language or image system may use PyTorch or TensorFlow. A quick experiment may happen in Jupyter before stable code moves into .py files.
Next, you will take this vocabulary off the whiteboard. Lesson 25.2 uses scikit-learn to train a small model, call fit, make predictions, and evaluate the result on test data.
Checkpoint
Answer all three to mark this lesson complete