lda_utils.visualize

Module Contents

Functions

_wordcloud_color_func_black(word,font_size,position,orientation,random_state=None,**kwargs)
write_wordclouds_to_folder(wordclouds,folder,file_name_fmt=”{label}.png”,**save_kwargs)
generate_wordclouds_for_topic_words(phi,vocab,top_n,topic_labels=”topic_{i1}”,which_topics=None,return_images=True,**wordcloud_kwargs)
generate_wordclouds_for_document_topics(theta,doc_labels,top_n,topic_labels=”topic_{i1}”,which_documents=None,return_images=True,**wordcloud_kwargs)
generate_wordclouds_from_distribution(distrib,row_labels,val_labels,top_n,which_rows=None,return_images=True,**wordcloud_kwargs)
generate_wordcloud_from_probabilities_and_words(prob,words,return_image=True,wordcloud_instance=None,**wordcloud_kwargs)
generate_wordcloud_from_weights(weights,return_image=True,wordcloud_instance=None,**wordcloud_kwargs)
plot_doc_topic_heatmap(fig,ax,doc_topic_distrib,doc_labels,topic_labels=None,which_documents=None,which_document_indices=None,which_topics=None,which_topic_indices=None,xaxislabel=None,yaxislabel=None,**kwargs) Plot a heatmap for a document-topic distribution doc_topic_distrib to a matplotlib Figure fig and Axes ax
plot_topic_word_heatmap(fig,ax,topic_word_distrib,vocab,which_topics=None,which_topic_indices=None,which_words=None,which_word_indices=None,xaxislabel=None,yaxislabel=None,**kwargs) Plot a heatmap for a topic-word distribution topic_word_distrib to a matplotlib Figure fig and Axes ax
plot_heatmap(fig,ax,data,xaxislabel=None,yaxislabel=None,xticklabels=None,yticklabels=None,title=None,grid=True,values_in_cells=True,round_values_in_cells=2,legend=False,fontsize_axislabel=None,fontsize_axisticks=None,fontsize_cell_values=None)
plot_eval_results(eval_results,metric=None,xaxislabel=None,yaxislabel=None,title=None,title_fontsize=”x-large”,axes_title_fontsize=”large”,**fig_kwargs) Plot the evaluation results from eval_results. eval_results must be a sequence containing (param, values)
_wordcloud_color_func_black(word, font_size, position, orientation, random_state=None, **kwargs)
write_wordclouds_to_folder(wordclouds, folder, file_name_fmt="{label}.png", **save_kwargs)
generate_wordclouds_for_topic_words(phi, vocab, top_n, topic_labels="topic_{i1}", which_topics=None, return_images=True, **wordcloud_kwargs)
generate_wordclouds_for_document_topics(theta, doc_labels, top_n, topic_labels="topic_{i1}", which_documents=None, return_images=True, **wordcloud_kwargs)
generate_wordclouds_from_distribution(distrib, row_labels, val_labels, top_n, which_rows=None, return_images=True, **wordcloud_kwargs)
generate_wordcloud_from_probabilities_and_words(prob, words, return_image=True, wordcloud_instance=None, **wordcloud_kwargs)
generate_wordcloud_from_weights(weights, return_image=True, wordcloud_instance=None, **wordcloud_kwargs)
plot_doc_topic_heatmap(fig, ax, doc_topic_distrib, doc_labels, topic_labels=None, which_documents=None, which_document_indices=None, which_topics=None, which_topic_indices=None, xaxislabel=None, yaxislabel=None, **kwargs)

Plot a heatmap for a document-topic distribution doc_topic_distrib to a matplotlib Figure fig and Axes ax using doc_labels as document labels on the y-axis and topics from 1 to n_topics=doc_topic_distrib.shape[1] on the x-axis. Custom topic labels can be passed as topic_labels. A subset of documents can be specified either with a sequence which_documents containing a subset of document labels from doc_labels or which_document_indices containing a sequence of document indices. A subset of topics can be specified either with a sequence which_topics containing sequence of numbers between [1, n_topics] or which_topic_indices which is a number between [0, n_topics-1] Additional arguments can be passed via kwargs to plot_heatmap.

Please note that it is almost always necessary to select a subset of your document-topic distribution with the which_documents or which_topics parameters, as otherwise the amount of data to be plotted will be too high to give a reasonable picture.

plot_topic_word_heatmap(fig, ax, topic_word_distrib, vocab, which_topics=None, which_topic_indices=None, which_words=None, which_word_indices=None, xaxislabel=None, yaxislabel=None, **kwargs)

Plot a heatmap for a topic-word distribution topic_word_distrib to a matplotlib Figure fig and Axes ax using vocab as vocabulary on the x-axis and topics from 1 to n_topics=doc_topic_distrib.shape[1] on the y-axis. A subset of words from vocab can be specified either directly with a sequence which_words or which_document_indices containing a sequence of word indices in vocab. A subset of topics can be specified either with a sequence which_topics containing sequence of numbers between [1, n_topics] or which_topic_indices which is a number between [0, n_topics-1] Additional arguments can be passed via kwargs to plot_heatmap.

Please note that it is almost always necessary to select a subset of your topic-word distribution with the which_words or which_topics parameters, as otherwise the amount of data to be plotted will be too high to give a reasonable picture.

plot_heatmap(fig, ax, data, xaxislabel=None, yaxislabel=None, xticklabels=None, yticklabels=None, title=None, grid=True, values_in_cells=True, round_values_in_cells=2, legend=False, fontsize_axislabel=None, fontsize_axisticks=None, fontsize_cell_values=None)

” helper function to plot a heatmap for a 2D matrix data using matplotlib’s “matshow” function

plot_eval_results(eval_results, metric=None, xaxislabel=None, yaxislabel=None, title=None, title_fontsize="x-large", axes_title_fontsize="large", **fig_kwargs)

Plot the evaluation results from eval_results. eval_results must be a sequence containing (param, values) tuples, where param is the parameter value to appear on the x axis and values can be a dict structure containing the metric values. eval_results can be created using the results_by_parameter function from the lda_utils.common module. Set metric to plot only a specific metric. Set xaxislabel for a label on the x-axis. Set yaxislabel for a label on the y-axis. Set title for a plot title.