Python Forum
Sentiment Analysis Classifier
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sentiment Analysis Classifier
#1

sentence = [sentence.__str__()]
classifier =LogisticRegression()
vectorizer = CountVectorizer()
x, y =data,sentiment

x_train, x_test,y_train, y_test = train_test_split(X,y)
sentiment_pipeline =Pipeline([('vectorizer',vectorizer),('classifier',classifier)])
sentiment_pipeline, confusion_matrix = cross_val_score(sentiment_pipeline, x_train, x_test )

My goal is to find the sentiment of the variable named 'sentence'. I get: ValueError: Found input variables with inconsistent numbers of samples: [1, 3] as an error. Any help would be greatly appreciated.

Imports concerning this is as follows:
from sklearn.feature_extraction.text import CountVectorizer
from nltk.sentiment import SentimentAnalyzer
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.pipeline import Pipeline
from sklearn.model_selection import cross_val_score

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [nltk] Naive Bayes Classifier constantin01 0 1,988 Jun-24-2019, 10:36 AM
Last Post: constantin01
  Attach sentiment to each word in a list of tuples Casper 3 3,744 Oct-13-2018, 02:02 PM
Last Post: ojirgl

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020