solving an easy problem first as we have seen when we looked at our tweet datathe tweets are not just positive or negative the majority of tweets actually do not contain any sentimentbut are neutral or irrelevantcontainingfor instanceraw information (new bookbuilding machine learning avoid complicating the task too muchlet us for now only focus on the positive and negative tweetspos_neg_idx=np logical_or( =="positive" =="negative" [pos_neg_idxy [pos_neg_idxy =="positivenowwe have in the raw tweet texts and in the binary classificationwe assign for negative and for positive tweets as we have learned in the beforewe can construct tfidfvectorizer to convert the raw tweet text into the tf-idf feature valueswhich we then use together with the labels to train our first classifier for conveniencewe will use the pipeline classwhich allows us to join the vectorizer and the classifier together and provides the same interfacefrom sklearn feature_extraction text import tfidfvectorizer from sklearn naive_bayes import multinomialnb from sklearn pipeline import pipeline def create_ngram_model()tfidf_ngrams tfidfvectorizer(ngram_range=( )analyzer="word"binary=falseclf multinomialnb(pipeline pipeline([('vect'tfidf_ngrams)('clf'clf)]return pipeline the pipeline instance returned by create_ngram_model(can now be used for fit(and predict(as if we had normal classifier since we do not have that much datawe should do cross-validation this timehoweverwe will not use kfoldwhich partitions the data in consecutive foldsbut instead we use shufflesplit this shuffles the data for usbut does not prevent the same data instance to be in multiple folds for each foldthenwe keep track of the area under the precision-recall curve and the accuracy