July 2018
Beginner to intermediate
406 pages
9h 55m
English
Once again, we simplified our task a bit, since we used only positive or negative tweets. That means, we assumed a perfect classifier that classified upfront whether the tweet contains a sentiment and forwarded that to our Naïve Bayes classifier.
So, how well do we perform if we also classify whether a tweet contains any sentiments at all? To find that out, let's first write a convenience function that returns a modified class array that provides a list of sentiments that we would like to interpret as positive:
def tweak_labels(Y, pos_sent_list): pos = Y==pos_sent_list[0] for sent_label in pos_sent_list[1:]: pos |= Y==sent_label
Y = np.zeros(Y.shape[0]) Y[pos] = 1 return Y.astype(int)
Note that we are talking about two ...
Read now
Unlock full access