m7n commited on
Commit
58962c9
·
verified ·
1 Parent(s): 5c81192

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -14
app.py CHANGED
@@ -180,17 +180,16 @@ def predict(text_input, progress=gr.Progress()):
180
 
181
  embeddings = create_embeddings(texts_to_embedd)
182
  print(embeddings)
183
-
184
-
185
-
186
-
187
-
188
-
189
-
190
-
191
-
192
-
193
-
194
 
195
 
196
 
@@ -203,10 +202,10 @@ def predict(text_input, progress=gr.Progress()):
203
  progress(0.7, desc="Loading hover data...")
204
 
205
  plot = datamapplot.create_interactive_plot(
206
- basedata_df[['x','y']].values,
207
  np.array(basedata_df['cluster_1_labels']),
208
- hover_text=[str(ix) + ', ' + str(row['parsed_publication']) + str(row['title']) for ix, row in basedata_df.iterrows()],
209
- font_family="Roboto Condensed",
210
  )
211
 
212
  progress(0.9, desc="Saving plot...")
 
180
 
181
  embeddings = create_embeddings(texts_to_embedd)
182
  print(embeddings)
183
+ 2d_embeddings = mapper.transform(embeddings)
184
+ records_df[['x','y']] = 2d_embeddings
185
+
186
+ basedata_df['color'] = '#ced4d211'
187
+ records_df['color'] = '#a81a26'
188
+
189
+ stacked_df = pd.concat([records_df, basedata_df], axis=0, ignore_index=True)
190
+ stacked_df = stacked_df.fillna("Unlabelled")
191
+
192
+
 
193
 
194
 
195
 
 
202
  progress(0.7, desc="Loading hover data...")
203
 
204
  plot = datamapplot.create_interactive_plot(
205
+ stacked_df[['x','y']].values,
206
  np.array(basedata_df['cluster_1_labels']),
207
+ hover_text=[str(ix) + ', ' + str(row['parsed_publication']) + str(row['title']) for ix, row in stacked_df.iterrows()],
208
+ font_family="Roboto Condensed",marker_color_array=stacked_df['color']
209
  )
210
 
211
  progress(0.9, desc="Saving plot...")