From the course: Hands-On AI: Build a Generative Language Model from Scratch

Unlock this course with a free trial

Join today to access over 23,200 courses taught by industry experts.

Solution: Comment filter

Solution: Comment filter

(upbeat music) - [Instructor] The goal of this challenge was to complete the classify method and label a comet from a social media site as potentially positive or potentially negative. We do this by adding up the positive and negative conditional probabilities of the tokens in the comment. Now, I should mention that in a typical naive base classifier, you would go through a step of coming up with what's called a Lambda score for each token, and in order to keep things as distilled as possible, we are just going to compare the sums of the probabilities. Let's see how this is done. Here at the classify method, I'm going to say that if the sum of the positives is larger than the sum of the negatives, I'm going to return "pos". Otherwise, if the sum of the negatives is larger, I'll return "neg". Finally, if they're the same, I'll return "neutral". Let's check this out now by running our code. And I got positive…

Contents