Unable to run this code on VScode

from texts import text_counter, text_training

from sklearn.feature_extraction.text import CountVectorizer

from sklearn.naive_bayes import MultinomialNB

intercepted_text = “I love my government.”

text_counts = text_counter.transform([intercepted_text])

text_classifier = MultinomialNB()

text_labels = [0] * 1000 + [1] * 1000

text_classifier.fit(text_training, text_labels)

final_pos = text_classifier.predict_proba(text_counts)[0][1]

final_neg = text_classifier.predict_proba(text_counts)[0][0]

if final_pos > final_neg:

print(“The text is positive.”)

else:
print(“The text is negative.”)

getting error:
from texts import text_counter, text_training
ModuleNotFoundError: No module named ‘texts’

Based on the error No module named 'texts', I would assume you are missing that module. Check the files in your lesson and check. You might have to download all dependencies in order to run it in your computer!

Also, for the next time you need help: How Do I format Code In My Posts?

2 Likes