Create app.py
Browse files
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 |
-
# ==================
|
50 |
-
st.
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
ax_kmeans.set_xlabel('PC1')
|
55 |
-
ax_kmeans.set_ylabel('PC2')
|
56 |
-
st.pyplot(fig_kmeans)
|
57 |
|
58 |
-
# ==================
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|