from the preceding output dimensionsyou can see that we have filtered out lot of the features we used previously when building our classification models by making min_df to be and max_df to be this is to speed up the topic modeling process and remove features that either occur too much or too rarely let' now import the necessary dependencies for the topic modeling process in [ ]import pyldavis import pyldavis sklearn from sklearn decomposition import nmf import topic_model_utils as tmu pyldavis enable_notebook(total_topics the nmf class from scikit-learn will help us with topic modeling we also use pyldavis for building interactive visualizations of topic models the core principle behind non-negative matrix factorization (nnmfis to apply matrix decomposition (similar to svdto non-negative feature matrix such that the decomposition can be represented as wh where are both non-negative matrices which if multiplied should approximately re-construct the feature matrix cost function like norm can be used for getting this approximation let' now apply nnmf to get topics from our positive sentiment reviews we will also leverage some utility functions from our topic_model_utils module to display the results in clean format in [ ]build topic model on positive sentiment review features pos_nmf nmf(n_components=total_topicsrandom_state= alpha= _ratio= pos_nmf fit(ptvf_featuresextract features and component weights pos_feature_names ptvf get_feature_names(pos_weights pos_nmf components_ extract and display topics and their components pos_topics tmu get_topics_terms_weights(pos_weightspos_feature_namestmu print_topics_udf(topics=pos_topicstotal_topics=total_topicsnum_terms= display_weights=falsetopic # without weights ['like''not''think''really''say''would''get''know''thing''much''bad''go''lot''could''even'topic # without weights ['movie''see''watch''great''good''one''not''time''ever''enjoy''recommend''make''acting''like''first'topic # without weights ['show''episode''series''tv''watch''dvd''first''see''time''one''good''year''remember''ever''would'topic # without weights ['performance''role''play''actor''cast''good''well''great''character''excellent''give''also''support''star''job'topic # without weights ['love''fall''song''wonderful''beautiful''music''heart''girl''would''watch''great''favorite''always''family''woman'