Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -264,7 +264,7 @@ def extract_problem_domains(df,
|
|
264 |
# Perform K-Means clustering with Silhouette Analysis
|
265 |
silhouette_scores = []
|
266 |
for n_clusters in range(cluster_range[0], cluster_range[1] + 1):
|
267 |
-
|
268 |
cluster_labels = kmeans.fit_predict(X)
|
269 |
silhouette_avg = silhouette_score(X, cluster_labels)
|
270 |
silhouette_scores.append(silhouette_avg)
|
@@ -293,9 +293,11 @@ def extract_problem_domains(df,
|
|
293 |
cluster_representations = {}
|
294 |
for i in range(optimal_n_clusters):
|
295 |
center = kmeans.cluster_centers_[i]
|
|
|
|
|
296 |
|
297 |
# top_word_indices = center.argsort()[-top_words:][::-1]
|
298 |
-
top_word_indices = center.argsort()[-top_words:][::-1].tolist()
|
299 |
|
300 |
top_words = [feature_names[index] for index in top_word_indices]
|
301 |
cluster_representations[i] = top_words
|
@@ -356,7 +358,7 @@ def nlp_pipeline(original_df, console_messages):
|
|
356 |
|
357 |
def process_excel(file):
|
358 |
console_messages = []
|
359 |
-
console_messages.append("Processing...")
|
360 |
|
361 |
try:
|
362 |
# Ensure the file path is correct
|
@@ -416,7 +418,7 @@ interface = gr.Interface(
|
|
416 |
# gr.File(label="Download the processed Excel File containing the ** Project Proposals ** for each Location~Problem paired combination"), # File download output
|
417 |
# gr.Textbox(label="Console Messages", lines=10, interactive=False) # Console messages output
|
418 |
# ],
|
419 |
-
|
420 |
outputs=[
|
421 |
gr.Textbox(label="Console Messages", lines=25, interactive=False), # Console messages output
|
422 |
gr.File(label="Download the processed Excel File containing the ** Project Proposals ** for each Location~Problem paired combination") # File download output
|
|
|
264 |
# Perform K-Means clustering with Silhouette Analysis
|
265 |
silhouette_scores = []
|
266 |
for n_clusters in range(cluster_range[0], cluster_range[1] + 1):
|
267 |
+
kmeans = KMeans(n_clusters=n_clusters)#, random_state=42)
|
268 |
cluster_labels = kmeans.fit_predict(X)
|
269 |
silhouette_avg = silhouette_score(X, cluster_labels)
|
270 |
silhouette_scores.append(silhouette_avg)
|
|
|
293 |
cluster_representations = {}
|
294 |
for i in range(optimal_n_clusters):
|
295 |
center = kmeans.cluster_centers_[i]
|
296 |
+
|
297 |
+
|
298 |
|
299 |
# top_word_indices = center.argsort()[-top_words:][::-1]
|
300 |
+
top_word_indices = center.argsort()[-top_words:][::-1].tolist() # Indexes of top words
|
301 |
|
302 |
top_words = [feature_names[index] for index in top_word_indices]
|
303 |
cluster_representations[i] = top_words
|
|
|
358 |
|
359 |
def process_excel(file):
|
360 |
console_messages = []
|
361 |
+
console_messages.append("Processing starts...")
|
362 |
|
363 |
try:
|
364 |
# Ensure the file path is correct
|
|
|
418 |
# gr.File(label="Download the processed Excel File containing the ** Project Proposals ** for each Location~Problem paired combination"), # File download output
|
419 |
# gr.Textbox(label="Console Messages", lines=10, interactive=False) # Console messages output
|
420 |
# ],
|
421 |
+
Use either below or above format
|
422 |
outputs=[
|
423 |
gr.Textbox(label="Console Messages", lines=25, interactive=False), # Console messages output
|
424 |
gr.File(label="Download the processed Excel File containing the ** Project Proposals ** for each Location~Problem paired combination") # File download output
|