SantanuBanerjee commited on
Commit
d050103
·
verified ·
1 Parent(s): 5756198

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -358,20 +358,26 @@ def extract_problem_domains(df,
358
  console_messages.append(f"Processing cluster {i}")
359
  console_messages.append(f"Center shape: {center.shape}, type: {type(center)}")
360
 
 
361
  if isinstance(center, np.ndarray) and center.ndim == 1:
362
  # Ensure center.argsort() returns a numpy array
363
- top_word_indices = center.argsort()[-top_words:][::-1]
364
- # top_word_indices = center.argsort()[-top_words:][::-1].tolist()
365
-
366
- if isinstance(top_word_indices, np.ndarray):
367
- top_word_indices = top_word_indices.tolist()
 
368
 
 
 
369
  console_messages.append(f"Top word indices for cluster {i}: {top_word_indices}")
 
370
  top_words = [feature_names[index] for index in top_word_indices]
371
  console_messages.append(f"Top words: {top_words}")
372
  cluster_representations[i] = top_words
373
  else:
374
  console_messages.append(f"Error: Cluster center is not a 1D array for cluster {i}")
 
375
 
376
 
377
  except Exception as e:
 
358
  console_messages.append(f"Processing cluster {i}")
359
  console_messages.append(f"Center shape: {center.shape}, type: {type(center)}")
360
 
361
+
362
  if isinstance(center, np.ndarray) and center.ndim == 1:
363
  # Ensure center.argsort() returns a numpy array
364
+ sorted_indices = center.argsort()
365
+ if isinstance(sorted_indices, np.ndarray):
366
+ sorted_indices = sorted_indices.tolist()
367
+
368
+ # Extract top word indices
369
+ top_word_indices = sorted_indices[-top_words:][::-1]
370
 
371
+ # Debug output
372
+ console_messages.append(f"Sorted indices: {sorted_indices}")
373
  console_messages.append(f"Top word indices for cluster {i}: {top_word_indices}")
374
+
375
  top_words = [feature_names[index] for index in top_word_indices]
376
  console_messages.append(f"Top words: {top_words}")
377
  cluster_representations[i] = top_words
378
  else:
379
  console_messages.append(f"Error: Cluster center is not a 1D array for cluster {i}")
380
+
381
 
382
 
383
  except Exception as e: