Bottom Page

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

buran wrote Feb-04-2019, 07:46 AM:
Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.

Please, post the entire traceback that you get. We need to see thе whole thing. Do not just give us the last line.
Take a time to read What to include in a post
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Plot/Image analysis %of colored area(grid) TiBotLCPP 0 145 Jul-09-2019, 02:33 PM
Last Post: TiBotLCPP
  [nltk] Naive Bayes Classifier constantin01 0 147 Jun-24-2019, 10:36 AM
Last Post: constantin01
  Market Basket Analysis: Finding Association Rules kylenater 1 250 Jun-21-2019, 03:53 AM
Last Post: scidam
  Statistical analysis of two dataframes zhl 1 459 Jun-11-2019, 07:26 PM
Last Post: Ecniv
  Fiber Photometry analysis Gius_ 0 204 May-12-2019, 09:14 PM
Last Post: Gius_
  PyCM 1.8 released: Machine learning library for confusion matrix statistical analysis sepandhaghighi 0 340 Jan-05-2019, 12:36 PM
Last Post: sepandhaghighi
  Load .abf file and for analysis with Pandas finalcode 0 440 Nov-10-2018, 09:51 AM
Last Post: finalcode
  Attach sentiment to each word in a list of tuples Casper 3 1,472 Oct-13-2018, 02:02 PM
Last Post: ojirgl
  Image Analysis for Measurement of Total leaf Area teamaqua 1 1,128 Aug-27-2017, 12:05 PM
Last Post: Larz60+
  Excel analysis SamB 3 1,837 Jul-04-2017, 09:52 PM
Last Post: zivoni

Forum Jump:


Users browsing this thread: 1 Guest(s)