cohere-ai / notebooks

Code examples and jupyter notebooks for the Cohere Platform
MIT License
451 stars 120 forks source link

Fixing Errors in Analyzing Hacker News Notebook [Topic Modeling] #159

Closed 0ssamaak0 closed 4 months ago

0ssamaak0 commented 4 months ago

1.Fixing error in bertopic

I replaced

from bertopic._ctfidf import ClassTFIDF

with

from bertopic.vectorizers import ClassTfidfTransformer

since it gives the error:

ModuleNotFoundError: No module named 'bertopic._ctfidf'

2.Fixing error in embed model

I replaced

query_embed = co.embed(texts=[query],
                  model="small-20220425", 
                  truncate="RIGHT").embeddings

with

query_embed = co.embed(texts=[query],
                  model="small", 
                  truncate="RIGHT").embeddings

since it gives the error:

CohereAPIError: model 'small-20220425' not found, make sure the correct model ID was used and that you have access to the model.

3. Fixing error in CountVectorizer

I replaced

words = count_vectorizer.get_feature_names()

with

words = count_vectorizer.get_feature_names_out()

since it gives the error:

AttributeError: 'CountVectorizer' object has no attribute 'get_feature_names'

The notebook now should work without any problems, I hope this help

CLAassistant commented 4 months ago

CLA assistant check
All committers have signed the CLA.

0ssamaak0 commented 4 months ago

@mrmer1 can you check this? thanks

mrmer1 commented 4 months ago

Hey @0ssamaak0. We happen to have another PR to make these and other changes as well, which we've just merged. Thanks for making these suggestions!

0ssamaak0 commented 4 months ago

Thanks 😁😁 you're amazing guys 🚀🚀