Skip to content

tSNE Updates#1400

Open
alexcarssuncao wants to merge 6 commits intoe-sensing:devfrom
alexcarssuncao:tsne
Open

tSNE Updates#1400
alexcarssuncao wants to merge 6 commits intoe-sensing:devfrom
alexcarssuncao:tsne

Conversation

@alexcarssuncao
Copy link
Copy Markdown
Contributor

@alexcarssuncao alexcarssuncao commented Sep 24, 2025

sits_tsne: expose perplexity/rounds, add LSTM-FCN & LightTAE support, fix plot palette

Summary

This PR improves the t-SNE workflow and model coverage in sits:

  • Parameters surfaced: perplexity and rounds are now explicit in sits_tsne() and stored in the result for reproducibility and plotting.
  • New model support: sits_tsne() now works with LSTM-FCN and the current sits_lighttae implementation.
  • Palette fix: Corrects the plot palette used by plot.sits_tsne().

Changes

  1. Add perplexity and rounds parameters to sits_tsne() and propagate them to the returned object (used by plotting/metadata).
  2. Add support for LSTM-FCN embeddings.
  3. Update compatibility with the current sits_lighttae version.
  4. Introduce model-identifying attributes/classes (e.g., "torch_model_mlp", "torch_model_tae", …) so sits_tsne() can route to the correct method.
  5. Fix color palette selection in plot.sits_tsne() so class colors match SITS conventions.

Implementation notes

  • sits_tsne() dispatches based on the model type; for now, I added attributes/classes to identify each torch model family.

Open question for maintainers

If there’s a preferred way to discover the concrete model without adding attributes, I’m happy to refactor. Possible alternatives:

  • Use an S3 class vector on the model object (e.g., class(model) <- c("torch_model_tae", "torch_model")) and keep sits_tsne.torch_model_tae() etc.
  • Add a small internal generic (e.g., .get_embeddings(model, x)) implemented per model type; sits_tsne() would call that.

Testing

  • Added/updated tests to verify:
    • Structure of the returned sits_tsne object across models.
    • Perplexity clamping (too large / negative) still returns a valid object.

EXPERIMENTAL

  • Attempted to fix the cpp issue in smooth.cpp:
    • Changed arma::is_finite() by std::infinite()

I’d appreciate any comments or suggestions—especially on the preferred mechanism for model-type dispatch (attribute vs. S3 class vector vs. helper generic).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants