Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -405,6 +405,16 @@ elif page == "KMeans Clustering & Recommendations":
|
|
| 405 |
plt.tight_layout()
|
| 406 |
st.pyplot(plt.gcf())
|
| 407 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 408 |
# Dynamic input for the new data point
|
| 409 |
st.subheader("Input New Data Point for Recommendations")
|
| 410 |
|
|
@@ -441,6 +451,7 @@ elif page == "KMeans Clustering & Recommendations":
|
|
| 441 |
|
| 442 |
st.subheader("Top 5 Similar Items to the Input")
|
| 443 |
st.write(f"The new data point belongs to cluster: {new_cluster}")
|
|
|
|
| 444 |
# Get all data points in the same cluster
|
| 445 |
cluster_data = df_original[df_original['cluster'] == new_cluster]
|
| 446 |
|
|
@@ -462,10 +473,10 @@ elif page == "KMeans Clustering & Recommendations":
|
|
| 462 |
recommendations = df_kiva_loans_cleaned.loc[recommended_indices]
|
| 463 |
|
| 464 |
# Display the original rows as the top 5 recommendations
|
| 465 |
-
|
| 466 |
st.write(recommendations)
|
| 467 |
|
| 468 |
|
|
|
|
| 469 |
# Page 8: Hierarchical Clustering & Dendrogram
|
| 470 |
elif page == "Hierarchical Clustering & Dendrogram":
|
| 471 |
st.subheader("Hierarchical Clustering & Dendrogram")
|
|
|
|
| 405 |
plt.tight_layout()
|
| 406 |
st.pyplot(plt.gcf())
|
| 407 |
|
| 408 |
+
# New Input: Select a cluster and display top 10 data points
|
| 409 |
+
st.subheader("Explore a Cluster")
|
| 410 |
+
selected_cluster = st.selectbox("Select a Cluster", options=sorted(df_original['cluster'].unique()))
|
| 411 |
+
|
| 412 |
+
# Filter data based on selected cluster
|
| 413 |
+
cluster_data = df_original[df_original['cluster'] == selected_cluster]
|
| 414 |
+
|
| 415 |
+
st.write(f"Top 10 items in Cluster {selected_cluster}:")
|
| 416 |
+
st.write(cluster_data.head(10))
|
| 417 |
+
|
| 418 |
# Dynamic input for the new data point
|
| 419 |
st.subheader("Input New Data Point for Recommendations")
|
| 420 |
|
|
|
|
| 451 |
|
| 452 |
st.subheader("Top 5 Similar Items to the Input")
|
| 453 |
st.write(f"The new data point belongs to cluster: {new_cluster}")
|
| 454 |
+
|
| 455 |
# Get all data points in the same cluster
|
| 456 |
cluster_data = df_original[df_original['cluster'] == new_cluster]
|
| 457 |
|
|
|
|
| 473 |
recommendations = df_kiva_loans_cleaned.loc[recommended_indices]
|
| 474 |
|
| 475 |
# Display the original rows as the top 5 recommendations
|
|
|
|
| 476 |
st.write(recommendations)
|
| 477 |
|
| 478 |
|
| 479 |
+
|
| 480 |
# Page 8: Hierarchical Clustering & Dendrogram
|
| 481 |
elif page == "Hierarchical Clustering & Dendrogram":
|
| 482 |
st.subheader("Hierarchical Clustering & Dendrogram")
|