What is the difference between supervised learning and unsupervised learning?
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Supervised learning and unsupervised learning are two fundamental paradigms in machine learning that address different types of problems and are applied based on the nature of the data and the problem domain. This article explores the technical differences, with examples, between these two learning paradigms.
Defining the Basics
Supervised Learning
Supervised learning is a type of machine learning where the algorithm learns from labeled training data. In this setup, each training example consists of an input object (usually a vector), and a desired output value or label:
- Objective: The goal is to learn a mapping from inputs to outputs based on the example input-output pairs.
- Training Data: Consists of pairs: , where is the input vector, and is the label, which indicates the output.
The major tasks within supervised learning include:
- Regression: Predicting a continuous-valued output. Example: Predicting house prices based on features like size, location, etc.
- Classification: Assigning an input to one of several discrete categories. Example: Classifying emails as spam or not spam.
Unsupervised Learning
Unsupervised learning involves training an algorithm using data that does not contain labels. Here, the system tries to learn the patterns and the structure from the input data:
- Objective: The aim is to infer the natural structure present in a set of data points.
- Training Data: Comprises only input data , and no output or target labels.
The primary tasks within unsupervised learning include:
- Clustering: Grouping a set of objects in such a way that objects in the same group (or cluster) are more similar than those in other groups. Example: Customer segmentation in marketing.
- Dimensionality Reduction: Reducing the number of random variables or features under consideration. Example: Principal Component Analysis (PCA).
Technical Explanations and Examples
- Supervised Learning Example:
Let's take a dataset containing features of houses and their associated prices. Using supervised learning, an algorithm can be trained to predict the price of a house based on its features like size, number of rooms, and location. Techniques such as linear regression, decision trees, and neural networks can be employed for this purpose. - Unsupervised Learning Example: Consider a dataset of customer purchase histories. Without any predefined labels, an algorithm like K-means can cluster these customers into different segments based on their purchasing patterns. These patterns might reveal groups like budget shoppers, luxury product buyers, etc., which were not explicitly labeled.
Comparison Table
| Feature/Aspect | Supervised Learning | Unsupervised Learning |
| Data Labels | Requires labeled data pairs | No labels required, only input data |
| Objective | Predict outcomes for new, unseen data | Discover hidden patterns or structure |
| Tasks | Classification, Regression | Clustering, Dimensionality Reduction |
| Scenarios | Where outcomes are known | Where relationships or patterns are unknown |
| Complexity | Can be computationally expensive | Generally less computationally intense |
Subtopics and Advanced Concepts
Semi-Supervised Learning
- A mix between supervised and unsupervised learning where the model is trained on a small amount of labeled data and a large amount of unlabeled data. This approach can reduce the cost of labeling.
Reinforcement Learning
- While distinct from both supervised and unsupervised learning, reinforcement learning involves learning through interactions with an environment to maximize cumulative rewards. It doesn't require labeled outputs but evaluates actions based on the received feedback.
Choosing Between Supervised and Unsupervised Learning
The choice between supervised and unsupervised learning depends heavily on the problem domain, the availability of labeled data, and the specific objectives of the task. When labeled data is abundant and the desired outcome is prediction or classification, supervised learning is preferred. Conversely, when exploring data to find inherent groupings or structures, unsupervised learning fits the bill.
Conclusion
Both supervised and unsupervised learning bring valuable perspectives and approaches in machine learning. Understanding their differences and appropriate application scenarios is crucial to solving diverse real-world problems efficiently. Each paradigm offers distinct methodologies and tools tailored to specific data scenarios and objectives.
Related reading
- What is the difference between SVC and SVM in scikit-learn?
- What is the difference between tensorflow inception and mobilenet
- What is the difference between tf-nightly and tensorflow in PyPI?
- What is the difference between TF Learn aka Scikit Flow and TFLearn aka TFLearn.org
- what is the difference between 'transform' and 'fit_transform' in sklearn
- What is the equivalent of np.std in TensorFlow?
- What is the difference between tf.estimator.Estimator and tf.contrib.learn.Estimator in TensorFlow
- What is the difference between tf.estimator.Estimator and tf.contrib.learn.Estimator in TensorFlow
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.