Creating and Assigning the Topic Model

Learn to create, assign, and plot the topic model in natural language processing tasks.

Creating the topic model

The create_model() function can be used to easily train a topic model on the preprocessed dataset. In this case, we train a LDA model with five topics, one for each of the dataset classes. After doing that, we use the assign_model() function that assigns the topic proportions to the dataset, as well as the dominant topic. Finally, we create a new dataset containing the topic proportions as well as the news article class, and print the first 10 instances.

Get hands-on with 1200+ tech skills courses.