Concepts / Visualizing High-Dimensional Data

Visualizing High-Dimensional Data

Unsupervised transformations are algorithms that create a new representation of a dataset, which may be easier for humans or other machine learning algorithms to understand.

  • Programming

A Dataset With No Answers

Most introductory machine learning examples start from a question that has a known answer, such as whether an email is spam or how much a house will sell for. The answer is attached to each example in advance, and the algorithm learns to predict it. Unsupervised learning is different. The data arrives without labels. Nobody has attached a correct answer to each example, so the algorithm cannot be told what to predict. Instead, it works directly with the data it is given.

This chapter looks at two kinds of unsupervised learning: transformations of the dataset and clustering. This article focuses on the first kind. Keep one question in mind as you read: if the data has no labels to guide the work, what can an algorithm usefully do with it? The answer this article develops is that it can describe the same data in a different way.

What a Representation Is

A dataset is always stored in some representation. Each example is described by a set of features, and the original representation is simply the set of features that were recorded. Think of a small table where every row is one example and every column is one feature. That table is one way of describing the data. Nothing forces the description to stay exactly as it is.

Trace the table below as you read. It is an illustrative example invented for this article, not data from the source. It has three examples, and each example is described by four recorded features. This is the original representation.

ExampleFeature 1Feature 2Feature 3Feature 4
Example A2.10.47.51.2
Example B3.00.96.81.5
Example C1.70.28.10.9

Original representation: three examples, each described by four features (generated illustration)

What do you think happens?

An unsupervised transformation is applied to the table above. How many examples does the new table contain?

  • Fewer than three, because some examples are removed

  • Exactly three, because the examples are the same data

  • More than three, because new examples are generated

Reveal answer
Answer:

Exactly three, because the examples are the same data

The transformation does not add new examples or remove the examples that were there. It changes how the examples are described, not how many examples there are.

The Transformation Step

Definition

An unsupervised transformation is an algorithm that creates a new representation of a dataset, which may be easier for humans or other machine learning algorithms to understand.

Two phrases in this definition carry most of the meaning. The first is new representation. The output is a different description of the same data. It is not a prediction and it is not a label. The second is easier to understand. The reason for creating the new description is usefulness. A transformation is judged by whether the new form helps a person or a downstream algorithm, not by whether it matches an answer that was given in advance.

Input datasetfeatures only, no labelsUnsupervisedtransformationno answers suppliedNew representationsame examples, newdescriptionoriginal formdifferent form
What are the steps from an input dataset through the unsupervised algorithm to the new representation, and where do labels fit in?

The pipeline has no label input because none exists. The algorithm takes the features as they are and produces the new description directly. Labels therefore do not enter the process at any stage. This is what separates the transformation from a supervised method, where the known answers guide the learning.

Dimensionality Reduction as Summarizing

A common application of unsupervised transformations is dimensionality reduction. Its starting point is a high-dimensional representation of the data, meaning a representation with many features for each example. Dimensionality reduction finds a new way to represent that same data so that the essential characteristics are still captured, but with fewer features.

Key point

The goal is summarizing. The new representation keeps the characteristics that matter most, using fewer numbers per example. It is not meant to keep every detail of the original.

Why Two Dimensions Helps Plotting

Reduction to two dimensions is a common choice for visualization. Two features can be drawn on a flat page or screen, with one feature on each axis. A dataset reduced to two dimensions can therefore be plotted and looked at directly. A dataset with four or forty features cannot be drawn that way, because a flat plot has only two axes to carry them.

Each sample in the two-dimensional output receives one pair of coordinates, an x value and a y value. The pair is the sample's location on the plot. The values below are invented for illustration and are not from the source.

Sample Ax = 1.3, y = 0.8Sample Bx = 2.6, y = 1.9Sample Cx = 0.4, y = 2.2
How does each sample get a pair of (x, y) coordinates in the 2D output, and why does that make the data viewable on a plot?

Original Versus New Representation

The same three examples now appear twice: once in their original representation and once in a new representation with two features each. The examples did not change identity. Only the description did. The diagram below compares the two states. The values are illustrative and generated for this article.

Example A4 featuresExample A2 featuresExample B4 featuresExample B2 featuresExample C4 featuresExample C2 featuresre-describedre-describedre-described
How does the same set of data points look in its original feature space compared with the new representation produced by the transformation?
AspectOriginal representationNew representation
What it containsThe features that were recorded for each exampleA different description of the same examples
Number of examplesThree in the illustrationStill three in the illustration
Features per exampleFour in the illustrationFewer, two in the illustration
PurposeStores the data as it was collectedAims to be easier for a person or another algorithm to work with

Contrast between the two representations (generated for this article)

Mistakes Beginners Make

  • Common mistake

    Thinking the transformation adds or removes examples

    What it looks like

    Assuming a table of three examples becomes a table of two after reduction.

    Why it fails

    The transformation does not add new examples or remove the examples that were there. It only changes how the examples are described.

    Do this instead

    Count examples before and after. The number should stay the same, while the number of features per example may change.

  • Common mistake

    Treating the output as a prediction or a label

    Why it fails

    The output is a new representation of the same data, not a predicted answer. The algorithm had no answers to predict in the first place.

    Do this instead

    Describe the output as a new description of the data and judge it by usefulness.

  • Common mistake

    Assuming reduction keeps every detail

    Why it fails

    The new representation is meant to keep the characteristics that matter most, in fewer numbers per example.

    Do this instead

    Expect some detail to be lost in exchange for a smaller, more usable description.

  • Common mistake

    Plotting data with more than two features directly

    Why it fails

    A flat plot has room for two axes. A dataset with four or forty features cannot be drawn directly on it.

    Do this instead

    Reduce the data to two dimensions first if the goal is a direct plot.

Practice: Reading a Transformed Table

EASY

A dataset has five examples, and each example is described by six features. An unsupervised transformation produces a new representation in which each example has two features. State how many examples and how many features per example the new representation has, and explain whether any examples were added or removed.

Hints
  • Separate the number of examples from the number of features per example.
  • Recall that the transformation changes how examples are described, not how many there are.

Key Takeaways

  • An unsupervised transformation takes a dataset without labels and produces a new representation of the same data, judged by whether it is easier for people or other algorithms to use.
  • The transformation does not add or remove examples. It changes how each example is described through its features.
  • Dimensionality reduction starts from a high-dimensional representation and finds a new one with fewer features while aiming to keep the essential characteristics.
  • Reducing data to two dimensions is useful for visualization because two features can be plotted directly, with one on each axis.

Related concepts

More concepts starting with V