示例#1
0
 def test_basic(self) -> None:
     mapper = bmm.LinearColorMapper()
     check_properties_existence(
         mapper,
         [
             "palette", "domain", "low", "high", "low_color", "high_color",
             "nan_color"
         ],
     )
vocab = cv.get_feature_names()
for i, topic_dist in enumerate(topic_word):
    topic_words = np.array(vocab)[np.argsort(topic_dist)][:-(n_top_words +
                                                             1):-1]  # get!
    topic_summaries.append(' '.join(topic_words))  # append!
print(topic_summaries)

dfb = pd.DataFrame()
dfb['content'] = df[idx_max].text.values.tolist()
dfb['topic_key'] = np.array(lda_keys)
dfb['X_tsne'] = tsne_lda[:, 0]
dfb['Y_tsne'] = tsne_lda[:, 1]

source = ColumnDataSource(dfb)
color_mapper = mappers.LinearColorMapper(palette=palettes.Category20_20,
                                         low=dfb.topic_key.min(),
                                         high=dfb.topic_key.max())

p = figure(plot_width=1200,
           plot_height=1000,
           title='t-SNE Lord of the Rings Topics',
           x_axis_label='X-coord',
           y_axis_label='Y-coord',
           tools="pan,wheel_zoom,box_zoom,reset,hover,previewsave",
           toolbar_location='above',
           min_border=1)
p.scatter(x='X_tsne',
          y='Y_tsne',
          color={
              'field': 'topic_key',
              'transform': color_mapper