Sentiment Analysis Classifier - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Sentiment Analysis Classifier (/thread-15864.html) |
Sentiment Analysis Classifier - lode - Feb-04-2019 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 |