View source: R/visualization_faces.R
| plot_embedding_space | R Documentation |
Creates a 2D visualization of face embeddings using dimensionality reduction, showing how faces cluster in the embedding space.
plot_embedding_space(
embeddings_df,
method = c("umap", "pca", "tsne"),
labels = NULL,
highlight = NULL,
n_neighbors = 15,
perplexity = 30
)
embeddings_df |
A tibble from |
method |
Dimensionality reduction method: "umap" (default), "pca", or "tsne". |
labels |
Optional character vector of labels for each point. |
highlight |
Optional indices of points to highlight (e.g., target position). |
n_neighbors |
For UMAP, number of neighbors. Default is 15. |
perplexity |
For t-SNE, perplexity parameter. Default is 30. |
This visualization helps understand:
How faces cluster by identity
Which foils are closest to the target in embedding space
Overall structure of similarity in a lineup
Only method = "pca" is a linear projection of the embeddings, and it
still loses most of the distance in the full embedding space. Distances in
UMAP and t-SNE plots are not interpretable, and with a lineup of six faces
the layout from either is close to arbitrary. Use method = "pca" for
a lineup, and read exact distances from lineup_similarity.
A ggplot2 object.
## Not run:
# Get embeddings for all lineup members
all_faces <- c("target.jpg", paste0("foil", 1:5, ".jpg"))
embs <- batch_embeddings(all_faces)
# Plot with target highlighted
plot_embedding_space(embs, method = "pca",
labels = c("Target", paste0("F", 1:5)), highlight = 1)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.