JERNGOC commited on
Commit
4df47b9
Β·
verified Β·
1 Parent(s): 82b4ab7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -24
app.py CHANGED
@@ -46,29 +46,36 @@ if uploaded_file is not None:
46
  # δ½Ώη”¨δΏε­˜ηš„ DBSCAN ζ¨‘εž‹ι€²θ‘Œθšι‘ž
47
  dbscan_labels = dbscan.fit_predict(pca_df)
48
 
49
- # ================== K-means θšι‘žεœ–θ‘¨ ==================
50
- st.subheader("K-means 聚鑞硐果")
51
- fig_kmeans, ax_kmeans = plt.subplots()
52
- ax_kmeans.scatter(pca_df['PC1'], pca_df['PC2'], c=kmeans_labels, cmap='viridis')
53
- ax_kmeans.set_title('K-means Clustering')
54
- ax_kmeans.set_xlabel('PC1')
55
- ax_kmeans.set_ylabel('PC2')
56
- st.pyplot(fig_kmeans)
57
 
58
- # ================== ιšŽε±€εΌθšι‘žεœ–θ‘¨ ==================
59
- st.subheader("階局式聚鑞硐果")
60
- fig_hclust, ax_hclust = plt.subplots()
61
- ax_hclust.scatter(pca_df['PC1'], pca_df['PC2'], c=hclust_labels, cmap='viridis')
62
- ax_hclust.set_title('Hierarchical Clustering')
63
- ax_hclust.set_xlabel('PC1')
64
- ax_hclust.set_ylabel('PC2')
65
- st.pyplot(fig_hclust)
 
66
 
67
- # ================== DBSCAN θšι‘žεœ–θ‘¨ ==================
68
- st.subheader("DBSCAN 聚鑞硐果")
69
- fig_dbscan, ax_dbscan = plt.subplots()
70
- ax_dbscan.scatter(pca_df['PC1'], pca_df['PC2'], c=dbscan_labels, cmap='viridis')
71
- ax_dbscan.set_title('DBSCAN Clustering')
72
- ax_dbscan.set_xlabel('PC1')
73
- ax_dbscan.set_ylabel('PC2')
74
- st.pyplot(fig_dbscan)
 
 
 
 
 
 
 
 
 
 
46
  # δ½Ώη”¨δΏε­˜ηš„ DBSCAN ζ¨‘εž‹ι€²θ‘Œθšι‘ž
47
  dbscan_labels = dbscan.fit_predict(pca_df)
48
 
49
+ # ================== εœ–θ‘¨ιΈζ“‡ ==================
50
+ chart_option = st.selectbox(
51
+ "ιΈζ“‡θ¦ι‘―η€Ίηš„θšι‘žη΅ζžœεœ–θ‘¨",
52
+ ("K-means", "階局式聚鑞", "DBSCAN")
53
+ )
 
 
 
54
 
55
+ # ================== ζ Ήζ“šιΈζ“‡ι‘―η€Ίε°ζ‡‰ηš„εœ–θ‘¨ ==================
56
+ if chart_option == "K-means":
57
+ st.subheader("K-means 聚鑞硐果")
58
+ fig_kmeans, ax_kmeans = plt.subplots()
59
+ ax_kmeans.scatter(pca_df['PC1'], pca_df['PC2'], c=kmeans_labels, cmap='viridis')
60
+ ax_kmeans.set_title('K-means Clustering')
61
+ ax_kmeans.set_xlabel('PC1')
62
+ ax_kmeans.set_ylabel('PC2')
63
+ st.pyplot(fig_kmeans)
64
 
65
+ elif chart_option == "階局式聚鑞":
66
+ st.subheader("階局式聚鑞硐果")
67
+ fig_hclust, ax_hclust = plt.subplots()
68
+ ax_hclust.scatter(pca_df['PC1'], pca_df['PC2'], c=hclust_labels, cmap='viridis')
69
+ ax_hclust.set_title('Hierarchical Clustering')
70
+ ax_hclust.set_xlabel('PC1')
71
+ ax_hclust.set_ylabel('PC2')
72
+ st.pyplot(fig_hclust)
73
+
74
+ elif chart_option == "DBSCAN":
75
+ st.subheader("DBSCAN 聚鑞硐果")
76
+ fig_dbscan, ax_dbscan = plt.subplots()
77
+ ax_dbscan.scatter(pca_df['PC1'], pca_df['PC2'], c=dbscan_labels, cmap='viridis')
78
+ ax_dbscan.set_title('DBSCAN Clustering')
79
+ ax_dbscan.set_xlabel('PC1')
80
+ ax_dbscan.set_ylabel('PC2')
81
+ st.pyplot(fig_dbscan)