Sign in to save

Bookmark this page so you can find it later.

Sign in to save

Bookmark this page so you can find it later.

Machine learning is a branch of statistics and computer science that finds patterns in data and uses them to make decisions or predictions. Two major approaches are supervised learning and unsupervised learning. The key difference is whether the training data includes known answers, called labels.

This distinction matters because it determines what questions a model can answer and how its performance is evaluated.

In supervised learning, the model learns a mapping from inputs to outputs, such as predicting a house price from its features or classifying an email as spam or not spam. In unsupervised learning, the model receives inputs without labels and searches for hidden structure, such as clusters, similarities, or lower-dimensional patterns. Supervised methods are often used for prediction, while unsupervised methods are often used for exploration and data understanding.

Many real projects use both, for example clustering customers first and then training a supervised model for each group.

Understanding Statistics: Supervised vs Unsupervised Learning

Labels are information collected by people, sensors, or past records. They are not automatically correct. A medical image may be labeled by an expert, while a delivery time may come from a company database.

Both can contain mistakes. A model learns from those mistakes as if they were facts. This is why preparing labeled data takes so much work.

People may need clear instructions so that two labelers make similar decisions. Labels can be missing for some groups, too. If a loan dataset contains mostly past decisions for one neighbourhood, a model may learn an unfair pattern from history rather than a fair rule.

A supervised model must be tested on examples it did not use during training. Students often see data divided into training, validation, and test sets. The training set is used to fit the model.

The validation set helps choose settings, such as how complex the model should be. The test set gives a final estimate of performance. Keeping these sets separate matters because a model can memorise training examples.

Memorising can produce excellent training results but poor results on new cases. This problem is called overfitting.

For number predictions, mean squared error finds the average of squared prediction differences. Squaring makes large mistakes count much more heavily than small ones.

Unsupervised learning has a different challenge because there is no answer sheet for checking success. A cluster is not automatically a real group in the world. The result depends on what measurements are included and how similarity is defined.

For example, customers grouped by spending may look very different from customers grouped by age and location. Measurements with large numerical ranges can dominate a distance calculation. A feature measured in thousands may overpower a feature measured from zero to ten.

Data is often scaled before clustering so each feature has a fairer influence. Students should inspect the groups, check whether they are useful, and remember that a computer-generated cluster is an interpretation rather than proof.

Unsupervised methods can reveal problems before a prediction model is built. They can find unusual sensor readings, repeated records, or groups that were not expected. A chart that reduces many measurements to two dimensions can help people see broad patterns, though it can hide detail.

In science, researchers may group stars by brightness and temperature before studying their types. In a music app, a system may group songs with similar audio features. These groups may then help create labels or suggest useful features for a later supervised task.

The most important habit is to match the method to the available evidence. Prediction needs reliable past outcomes that are relevant to the future decision. Exploration is useful when the structure of the data is still unknown.

In both cases, data quality matters more than a complicated algorithm. Check where the data came from, what each feature really measures, and who may be missing from the dataset. A model can calculate quickly, but it cannot fix a vague target, biased records, or a poorly chosen measurement.

Key Facts

  • Supervised learning uses labeled data: training examples have inputs x and known outputs y.
  • Unsupervised learning uses unlabeled data: examples have inputs x but no target output y.
  • A supervised model often learns a function written as y = f(x) + error.
  • Classification predicts categories, such as spam or not spam, while regression predicts numbers, such as price or temperature.
  • Clustering is an unsupervised task that groups similar data points based on a distance or similarity measure.
  • A common supervised error measure is mean squared error: MSE = (1/n) sum(yi - yhat_i)^2.

Vocabulary

Label
A label is the known answer or target value attached to a training example, such as a class name or numerical outcome.
Feature
A feature is an input variable used by a model, such as height, age, color, income, or word count.
Classification
Classification is a supervised learning task in which the model predicts which category an example belongs to.
Regression
Regression is a supervised learning task in which the model predicts a numerical value.
Clustering
Clustering is an unsupervised learning task that groups data points so that points in the same group are more similar to each other than to points in other groups.

Common Mistakes to Avoid

  • Calling every prediction problem unsupervised is wrong because prediction with known target answers is usually supervised learning.
  • Using labels during clustering is wrong because standard clustering methods are meant to find groups without being told the correct group names.
  • Treating classification and regression as the same task is wrong because classification predicts categories while regression predicts numerical values.
  • Judging an unsupervised model only by accuracy is wrong because accuracy requires true labels, and unlabeled tasks often need measures such as silhouette score, reconstruction error, or human interpretation.

Practice Questions

  1. 1 A dataset has 1,000 emails, and each email is labeled spam or not spam. A model correctly classifies 920 emails. What is the accuracy as a percent?
  2. 2 For a regression model, the true values are 3, 5, and 10, and the predicted values are 2, 7, and 9. Compute the mean squared error using MSE = (1/n) sum(yi - yhat_i)^2.
  3. 3 A store has customer purchase histories but no labels such as budget shopper or premium shopper. Should the store begin with supervised or unsupervised learning to discover customer groups, and why?