koaning/whatlies

Rename internal files to prevent import errors.

Closed this issue · 4 comments

Testing the examples in Notebook, I'm encountering an error on the UMAP example. Any ideas?


# orig_chart = emb.plot_interactive('man', 'woman')
pca_plot = emb.transform(pca(2)).plot_interactive('pca_0', 'pca_1')

emb.transform(umap(2)).plot_interactive('umap_0', 'umap_1')
<ipython-input-5-18f8db210390> in <module>
      2 
      3 # orig_chart = emb.plot_interactive('man', 'woman')
----> 4 pca_plot = emb.transform(pca(2)).plot_interactive('pca_0', 'pca_1')
      5 
      6 emb.transform(umap(2)).plot_interactive('umap_0', 'umap_1')

TypeError: 'module' object is not callable```

Ah! This is a capitalisation issue. From the top of my head this should work:

from whatlies.transformer import Pca
pca_plot = emb.transform(Pca(2)).plot_interactive('pca_0', 'pca_1')

Note the capital P in Pca. Same would go for Umap and the others.

You got this error because this is because the Pca object is implemented over at whatlies.transformer.pca. We should correct this because this is a common error. It would be better if our internal files followed the following name convention: whatlies.transformer._pca. This should prevent a whole lot of buggery.

Aside

This is an aside, but I'll be releasing a new version today such that you no longer have to run:

emb.transform(Pca(2)).plot_interactive('pca_0', 'pca_1')

And instead you can run:

emb.transform(Pca(2)).plot_interactive()

Internally we are assming the first two elements of the vectors for those charts. As such, you'd get the same chart just with less characters. It will take a while to reflect these changes in the documentation.

Would you mind if I change the name of this issue to reflect the internal name change that needs to happen?

That did the trick. Thank you! Feel free to change the issue name.

I'm loving the library btw -- word analysis has taken the place of sleep this evening.

I'm happy to hear you enjoy the library!

If you ever end up doing something interesting with our tool, feel free to reach out and share it with us. We're trying to collect interesting examples here and we're certainly open to contributions.