0
0
ML Pythonml~8 mins

t-SNE for visualization in ML Python - Model Metrics & Evaluation

Choose your learning style9 modes available
Metrics & Evaluation - t-SNE for visualization
Which metric matters for t-SNE visualization and WHY

t-SNE is a tool to show complex data in 2D or 3D so we can see patterns. It does not predict or classify, so usual accuracy metrics do not apply.

Instead, we look at how well t-SNE keeps similar points close and different points apart. This is often checked by visual inspection or by measuring trustworthiness and continuity scores.

These scores tell us if neighbors in the original data stay neighbors in the t-SNE map (trustworthiness), and if neighbors in the map were neighbors before (continuity).

Confusion matrix or equivalent visualization

t-SNE does not produce a confusion matrix because it is not a classifier.

Instead, we use a scatter plot showing points colored by their true group or label.

    Example t-SNE plot:

    +------------------------------------------------+
    |  *  *     *      *      *      *      *      *  |
    | * Group A points clustered together clearly    |
    |                                                |
    |        ++++++   ++++++   ++++++                |
    |        + Group B points clustered separately   |
    |                                                |
    |  o  o  o      o      o      o      o      o    |
    |  o Group C points scattered or overlapping     |
    +------------------------------------------------+
    

This visual helps us see if t-SNE separated groups well.

Precision vs Recall tradeoff (or equivalent) with concrete examples

t-SNE does not have precision or recall because it is not a classifier.

Instead, there is a tradeoff between local structure and global structure preservation.

  • Local structure: How well close points stay close. Good for seeing clusters.
  • Global structure: How well overall distances between clusters are kept. Good for understanding big picture.

For example, if you want to see tight clusters of similar items, focus on local structure (trustworthiness). If you want to see how clusters relate overall, focus on global structure (continuity).

What "good" vs "bad" metric values look like for t-SNE visualization

Good t-SNE visualization:

  • Clear, separate clusters matching known groups.
  • High trustworthiness score (close to 1.0), meaning neighbors are preserved.
  • Reasonable continuity score, meaning map neighbors reflect original neighbors.
  • Visual patterns that match what you expect from the data.

Bad t-SNE visualization:

  • Clusters overlap heavily or are mixed up.
  • Low trustworthiness (much less than 1.0), meaning neighbors are lost.
  • Map looks random or noisy with no clear groups.
  • Visual patterns contradict known labels or data structure.
Common pitfalls when evaluating t-SNE visualizations
  • Overinterpreting distances: Distances between clusters in t-SNE plots are not always meaningful globally.
  • Ignoring randomness: t-SNE uses randomness; different runs can look different. Always run multiple times.
  • Misleading clusters: t-SNE can create apparent clusters even if none exist in data.
  • Parameter sensitivity: Perplexity and learning rate affect results a lot; poor choices can ruin visualization.
  • Not checking trustworthiness: Without metrics, visual patterns can be misleading.
Self-check question

Your t-SNE plot shows three clear clusters matching your labels, but the trustworthiness score is 0.6 (low). Is this visualization reliable? Why or why not?

Answer: No, it is not fully reliable. The low trustworthiness means neighbors in the original data are not well preserved. The clusters might look clear but could be misleading. You should try different parameters or check other metrics before trusting the plot.

Key Result
t-SNE evaluation focuses on trustworthiness and continuity scores to ensure local and global data structure are preserved in visualization.