Recommended resources
The freely available resources this lesson will direct you to.
Welcome to the first lesson of our second module, "Core Concepts of Supervised Learning." In the previous module, we established the theoretical bedrock for machine learning, culminating in the principle of Empirical Risk Minimization (ERM). We saw that learning from data can be framed as an optimization problem: finding a model that minimizes the average error on a given dataset. This principle serves as the formal justification for how algorithms learn.
Now, we will pivot from the "how" to the "what." This lesson formally defines machine learning itself. We will contrast it with the traditional programming paradigm you have mastered and explore why this shift in thinking has become one of the most significant transformations in computer science. By the end of this lesson, you will be able to define machine learning and articulate its fundamental differences from rule-based programming using compelling, real-world examples.
A Fundamental Shift in Programming Paradigm
In traditional computing, the relationship between data, program, and output is clear and direct. A human developer analyzes a problem, devises an explicit set of rules and logic, and implements them as a program. The computer then executes this program on input data to produce an output. You, as the programmer, are the source of the logic.
Machine learning inverts this process. Instead of writing the rules, you provide the computer with examples—input data and the corresponding desired outputs. The machine learning algorithm's job is to infer the rules that map the inputs to the outputs. In essence, the algorithm writes the program for you.
This short video from an MIT OpenCourseWare lecture provides an excellent articulation of this paradigm shift.
11. Introduction to Machine Learning
This video, "Introduction to Machine Learning," clearly contrasts the traditional and ML programming flows.
Please watch the segment from the introduction to the core idea. The lecturer draws a diagram that perfectly visualizes this inversion: Normal Programming: Program + Data → Computer → Output Machine Learning: Data + Output → Computer → Program
This inversion from explicit instruction to automated inference is the defining characteristic of machine learning. A set of lecture notes from Cornell University offers a similarly crisp visual distinction.
[PDF] 6781: Theoretical Foundations of Machine Learning
These notes introduce the core concepts of ML theory.
On the third slide, observe the diagram titled "What is Machine Learning?". It contrasts "Traditional Computing" with "Machine Learning" by showing how the program moves from being an input to being an output of the computational process.
A Formal Definition
While the conceptual shift is intuitive, a more formal definition is necessary. The most widely cited definition comes from computer scientist Tom Mitchell (1997):
"A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P, if its performance at tasks in T, as measured by P, improves with experience E."
Let's dissect this definition using a classic example: spam email detection.
- Task (T): The task is to classify an incoming email as either "spam" or "not spam."
- Experience (E): The experience is a large dataset of emails, where each email has been manually labeled by a human as spam or not spam. This labeled dataset is the "training data."
- Performance (P): The performance measure is the accuracy of the classification, i.e., the percentage of emails the program correctly classifies.
According to Mitchell's definition, a program learns to detect spam if its classification accuracy (P) improves as it is given more labeled emails (E) to learn from.
The "Software 2.0" Stack
A more contemporary and powerful way to frame this paradigm shift, particularly for those with a deep background in software engineering, is Andrej Karpathy's concept of Software 2.0.
- Software 1.0: This is the classical software stack you are familiar with—code written in languages like Python, C++, Java, etc. It is written by humans, maintained in version control systems, and composed of explicit algorithms and data structures.
- Software 2.0: This is code written in the "weights" of a neural network (or other ML model). It is not written by a human. Instead, a human programmer specifies a goal (e.g., via an objective function like the empirical risk we studied), provides a dataset, and lets an optimization algorithm search the vast space of possible programs (models) for one that achieves the goal.
The following clip of Andrej Karpathy, former Director of AI at Tesla, provides a brilliant first-person account of this idea.
Andrej Karpathy on Software 2.0 at Tesla
In this clip, Andrej Karpathy introduces his influential "Software 2.0" concept.
Watch the initial segments where he lays out the core idea: First, listen to his motivation for coining the term, where he describes seeing software being written not in C++, but in the weights of a neural net. Next, he contrasts the programming methodologies. Software 1.0 is writing C++ code directly. Software 2.0 involves accumulating training sets, crafting objectives, and specifying an architecture, which then gets "compiled" by an optimizer into a deployable model.
This image provides a clean, concrete example of the distinction.
The logic for a Software 1.0 sentiment classifier is transparent but brittle. It will fail on sarcasm, nuanced language, or any words not in its predefined lists. The Software 2.0 approach learns these nuances directly from data, making it far more robust and scalable.
A Real-World Case Study: Tesla Autopilot
The abstract distinction becomes concrete when applied to problems of immense complexity. Karpathy explains how this transition was not just an academic exercise at Tesla but a practical necessity.
Andrej Karpathy on Software 2.0 at Tesla
Let's continue with the same video to see how this played out in a high-stakes, real-world system.
First, he describes the evolution of image classification, from hand-designing algorithms in the 80s to learning features and entire systems with neural networks. The key insight was realizing that humans are not very good at designing complex feature extractors. Next, he gives a specific, detailed example from Tesla's Autopilot. The team transitioned from a Software 1.0 system with C++ code manually fusing data from eight cameras to a Software 2.0 system where a single, large neural network learns to perform this fusion automatically. The explicit reason he gives is critical: "we're actually not good enough to write that algorithm."
This case study is a powerful illustration of the core trade-off. For problems where the rules are astronomically complex—like interpreting and fusing noisy video streams from multiple viewpoints to build a 3D understanding of the world in real-time—the Software 1.0 approach of explicit, human-authored logic breaks down. The Software 2.0 approach, which learns the logic from data, becomes the only viable path forward.
Rule-Based vs. Data-Driven: Explainability and Trust
The contrast between these two paradigms also brings up critical system design considerations, particularly around explainability and trust.
- Rule-Based Systems (Software 1.0): These are inherently transparent or "white-box." Since a human wrote the rules, the system's decision-making process is auditable and explainable. If the system makes a mistake, you can trace the exact line of code and logical condition that caused it.
- Machine Learning Systems (Software 2.0): These can often be "black-box." A deep neural network with billions of parameters may achieve superhuman performance, but explaining why it made a specific decision can be incredibly difficult. This lack of transparency can be a major barrier to adoption in high-stakes domains like medicine or law.
This diagram illustrates the trade-off in a cybersecurity context.

This highlights a central tension in modern AI system design. While the data-driven approach of machine learning unlocks capabilities that are impossible with rule-based programming, it often comes at the cost of interpretability. A significant area of ML research, known as Explainable AI (XAI), is dedicated to developing techniques to bridge this gap.
Conclusion
In this lesson, we have formally defined machine learning and contrasted its data-driven, bottom-up paradigm with the rule-based, top-down approach of traditional programming.
Here are the key takeaways:
- Paradigm Inversion: Traditional programming involves a human writing rules (a program) to process data. Machine learning involves using data and desired outputs to automatically infer the rules.
- Formal Definition (Mitchell): An algorithm learns if its performance (P) on a task (T) improves with experience (E).
- Software 2.0: This is a powerful mental model that casts ML models as a new kind of software, one written by optimizers processing data rather than by humans writing explicit lines of code.
- Core Trade-off: Rule-based systems are suitable for problems with well-defined, stable logic and offer high transparency. Machine learning excels at problems whose logic is too complex for humans to specify, but this often comes at the cost of explainability.
You now have a clear, formal understanding of what defines machine learning. So far, we've treated "machine learning" as a single entity. However, the field is comprised of several distinct paradigms. In our next lesson, we will dissect machine learning into its three main categories: supervised, unsupervised, and reinforcement learning.