This is the data i use count vectorizer and tfidftransformer and also use GaussianNB but i get error in this code. Please let me know the correct syntax.
train = [('I love this sandwich.','pos'),
('This is an amazing place!', 'pos'),
('I feel very good about these beers.', 'pos'),
('This is my best work.', 'pos'),
('What an awesome view', 'pos'),
('I do not like this restaurant', 'neg'),
('I am tired of this stuff.', 'neg'),
("I can't deal with this.", 'neg'),
('He is my sworn enemy!.', 'neg'),
('My boss is horrible.', 'neg')
]
from sklearn.feature_extraction.text import CountVectorizer
cv = CountVectorizer()
text_train_cv = cv.fit_transform(list(zip(*train))[0])
print(text_train_cv.toarray())
from sklearn.feature_extraction.text import TfidfTransformer
tfidf_trans = TfidfTransformer()
text_train_tfidf = tfidf_trans.fit_transform(text_train_cv)
print(text_train_tfidf.toarray())
from sklearn.naive_bayes import GaussianNB
clf = GaussianNB().fit(text_train_tfidf.toarray(), list(zip(*train))[1])
text_clf = Pipeline([('vect',CountVectorizer(stop_words='english')),
('tfidf',TfidfTransformer()),('clf',GaussianNB(priors=None))])
text_clf = text_clf.fit(text_train_tfidf.toarray() , list(zip(*train))[1])
print(text_clf)
It give me error: AttributeError: 'numpy.ndarray' object has no attribute 'lower'