So in this lecture, we'll be looking at the notebook to demonstrate an AMF note that the format of
this notebook will be very similar to LDA.
So we'll go through most of it fairly quickly as before we'll begin by downloading the BBC news dataset.
The next step is to do our imports.
Note that this time we'll be using animal with TFI Taf.
So why is it OK to use TFI off with enemies?
As you recall, the reason we use simple counts with LDA is because that it corresponds with the multi
distribution, which is part of the LDA model.
The next step is to download or stop words.
The next step is to convert our list of stop words into a set.
The next step is to add additional stop words.
The next step is to load in our data using PDF that reads Feed.
The next step is to remind ourselves what this data looks like.
The next step is to create our TF IDF factories are objects passing in the Stoppard's we define above.
The next step is to transform our text into a 240 of matrix.
The next step is to create our nymph object again, we'll choose 10 components, note that for the loss,
we use the kale divergence, which when you do corresponds with probabilistic latent semantic analysis.
Another way of looking at this is the paper on probabilistic lean semantic analysis really just describes
non-negative matrix factorization with kale divergence as the laws.
Note that when you use this loss, it's required that you specify the solver as AMU, which stands for
multiplicative update.
Note that it's also possible to regularize the weights, but I've commented this out since it's not
needed.
Finally, note that I've set the random state to zero so that we obtain a consistent results.
The next step is to fit our model.
The next step is due to find the plot, top words function once again.
The next step is to call the plot top where its function once again.
OK, so let's have a look at these topics to make sure that they make sense.
So the top words for the first topic are people, UK, mobile, U.S. music and so forth.
So probably mobile technology is a good way to summarize this topic.
The top words for the second topic are Labour Election, The Blair Party and so forth.
So clearly, this is about politics.
Four topic three, we have England win, Wales, Ireland injury, rugby coach and so forth.
Clearly, this is about sports and specifically rugby.
For topic for we have film a best awards and so forth.
So this is entertainment for Topic five, we have growth economy bank and so forth.
So this is economics.
And again, check out all the other topics as an exercise.
The next step is to transform our data to get back the documents by topics matrix.
The next step is to plot the topics for a randomly chosen input sample.
As you can see, the true label is sport in the strongest topic is topic three, by the way.
Note that unlike LDA, these values do not sum to one.
So let's scroll back up and remind ourselves what Typekit three represents.
OK, so topic three is related to sports and specifically rugby.
So let's prints out this article to make sure that our topic makes sense.
So the article is Chavez said, to lose fitness bit.
So these results make perfect sense, since Chavez is in fact a former rugby player.