Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.7 Migration #7

Open
extrospective opened this issue Mar 26, 2019 · 0 comments
Open

Python 3.7 Migration #7

extrospective opened this issue Mar 26, 2019 · 0 comments

Comments

@extrospective
Copy link

extrospective commented Mar 26, 2019

Suggested modifications for modern-nlp-in-python/executable/Modern_NLP_in_Python.ipynb:

# Change tuple reference in sorted to use third term rather than multi-parameter lamba func:
ordered_vocab = sorted(ordered_vocab, key=lambda x: -x[2])

# Change 'w' to 'wb' when writing binary pickle file:
with open(tsne_filepath, 'wb') as f:

# Add 'rb' as argument rather than default argument:
with open(tsne_filepath, 'rb') as f:


# --------------------------------------
# bokeh unfortunately is not working when I pull this up so we do not get to see the visualization

# Tetsted with my own data (rather than yelp data), this code may help someone get started:
%matplotlib inline
import matplotlib.pyplot as plt

tsne_vectors.plot.scatter('x_coord', 'y_coord', figsize=(14,14))
ax = plt.gca()

for cntr, txt in enumerate(tsne_vectors.index):
    ax.annotate(txt, (tsne_vectors[tsne_vectors.index==txt].x_coord, tsne_vectors[tsne_vectors.index==txt].y_coord))
    if cntr > 50:
        # for demo purposes label an arbitrary set of points
        break
plt.show()
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

No branches or pull requests

1 participant