Skip to content
Discussion options

You must be logged in to vote

Hi @MaartenGr , I found the difference between what BERTopic() does and what I was doing.

If instead of:

reducer = PCA(n_components=13, random_state=42)
reduced_embeddings = reducer.fit_transform(embeddings)

I do:

reducer = PCA(n_components=13, random_state=42)
reducer.fit(embeddings)
reduced_embeddings = reducer.transform(embeddings)

Then the outputs of both approaches will align, as this latter one matches the behaviour of BERTopic._reduce_dimensionality(). Was expecting self.umap_model.fit(embeddings) followed by umap_embeddings = self.umap_model.transform(embeddings) to be equivalent to self.umap_model.fit_transform(embeddings), but apparently this is not the case!

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@JWOsmond
Comment options

@MaartenGr
Comment options

@JWOsmond
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by JWOsmond
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants