-
現状
- 自然言語処理において,nlplotライブラリを使うことで単語の頻度カウントやワードクラウドの表示を行おうとした
- サンプルコード(下記「参考サイト」を参照)を実行したところ,ワードクラウドの表示はできたが,他のグラフが出てこない
- N-gram bar chartはエラーにはならず,何かしらがアウトプットされているように見える(グラフの枠線なども出てこない)
- 分析環境
- 環境:Amazon Sagemaker Studio
- ライブラリバージョン:1.4.0
-
やりたいこと
- ワードクラウド以外のグラフ(特にN-gram bar chart)を表示したい
-
ご依頼
- どなたかサンプルコードを実行して,私と同じ結果になるのかご確認いただけないでしょうか
- グラフ化できない原因に心当たりがありましたら,ご教授いただきたいです
-
サンプルコード(参考サイトより抜粋)
# sample data target_col = "text" texts = [ "Think rich look poor", "When you come to a roadblock, take a detour", "When it is dark enough, you can see the stars", "Never let your memories be greater than your dreams", "Victory is sweetest when you’ve known defeat" ] df = pd.DataFrame({target_col: texts}) df.head()
import nlplot # target_col as a list type or a string separated by a space. npt = nlplot.NLPlot(df, target_col='text') # Stopword calculations can be performed. stopwords = npt.get_stopword(top_n=30, min_freq=0) # 1. N-gram bar chart npt.bar_ngram(title='uni-gram', ngram=1, top_n=50, stopwords=stopwords) npt.bar_ngram(title='bi-gram', ngram=2, top_n=50, stopwords=stopwords) # 2. N-gram tree Map npt.treemap(title='Tree of Most Common Words', ngram=1, top_n=30, stopwords=stopwords) # 3. Histogram of the word count npt.word_distribution(title='words distribution') # 4. wordcloud npt.wordcloud(stopwords=stopwords, colormap='tab20_r') # 5. co-occurrence networks npt.build_graph(stopwords=stopwords, min_edge_frequency=10) # The number of nodes and edges to which this output is plotted. # If this number is too large, plotting will take a long time, so adjust the [min_edge_frequency] well. >> node_size:70, edge_size:166 npt.co_network(title='Co-occurrence network') # 6. sunburst chart npt.sunburst(title='sunburst chart', colorscale=True)

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。