src.plot_latents
plot_latents.py
Visualize latent representations from an autoencoder using dimensionality reduction.
This script: - Loads latent feature vectors and labels from a compressed .npz file. - Computes the Silhouette Score using cosine distance (if labels are available). - Applies dimensionality reduction (UMAP or PCA) to project the latent space to 2D. - Displays a scatter plot of the embedded data, optionally saving the plot.
- Usage:
python plot_latents.py –input path/to/X_latent_data.npz –method umap –save
Functions
|
Extract fold number (e.g., 'fold3') from folder or file path. |
|
Extract model suffix (e.g., 'B') from folder name like 'latent_len295_B_fold2'. |
|
Extract segment length (e.g. 295) from path like 'latent_len295_fold4'. |
|
Load latent vectors and labels from a .npz file. |
|
Main function to load latent data, compute Silhouette Score, and visualize embeddings. |
|
Reduce dimensionality of latent space and generate a scatter plot. |