I am doing a project on Twitter tweet sentiment analysis following a project on a blog (link at the bottom), and I am getting the following error when running the code on Google Colab:
ValueError: Found input variables with inconsistent numbers of samples: [2, 41157]
Here are the procedures I have gone through:
First I read a CSV file with 41,157 tweets as training data.
Then, I ran a regular expression function to remove any symbols and special characters to get pure data
I converted the text into the matrix of tokens
I get the error when running the following:
(LabelEncoder is used here for transforming categorical values into numerical values.)
Can someone tell me what might have gone wrong? Help would be appreciated!
Here is the URL to the project I am learning from: https://www.analyticsvidhya.com/blog/202...th-python/
ValueError: Found input variables with inconsistent numbers of samples: [2, 41157]
Here are the procedures I have gone through:
First I read a CSV file with 41,157 tweets as training data.
Then, I ran a regular expression function to remove any symbols and special characters to get pure data
I converted the text into the matrix of tokens
I get the error when running the following:
(LabelEncoder is used here for transforming categorical values into numerical values.)
1 2 3 4 5 6 7 8 |
X_train = vectoriser.fit_transform(df[ "CleanedTweet" ]) # Encoding the classes in numerical values from sklearn.preprocessing import LabelEncoder encoder = LabelEncoder() y_train = encoder.fit_transform(df[ 'Sentiment' ]) from sklearn.naive_bayes import MultinomialNB classifier = MultinomialNB() classifier.fit(X_train, y_train) |
Here is the URL to the project I am learning from: https://www.analyticsvidhya.com/blog/202...th-python/
Larz60+ write Dec-26-2021, 09:39 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.