JUNGU commited on
Commit
7333f3f
·
1 Parent(s): 26cdcf1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -13
app.py CHANGED
@@ -37,18 +37,22 @@ def main():
37
  "인구밀집도": population_df
38
  }
39
 
40
- combined_data = pd.concat([dataset_mapping[dataset_name] for dataset_name in datasets])
41
-
42
- fig, ax = plt.subplots(figsize=(8, 8))
43
-
44
- centroids, labels = apply_kmeans(combined_data.values, k_value)
45
- ax.scatter(combined_data['x'], combined_data['y'], c=labels, cmap='viridis')
46
- ax.scatter(centroids[:, 0], centroids[:, 1], s=200, c='red', marker='X')
47
-
48
- ax.set_xlim(0, 100)
49
- ax.set_ylim(0, 100)
50
- ax.set_title(f"K-means clustering result (k={k_value})")
51
- st.pyplot(fig)
 
 
52
 
53
  if __name__ == "__main__":
54
- main()
 
 
 
37
  "인구밀집도": population_df
38
  }
39
 
40
+ # Check if any dataset is selected
41
+ if datasets:
42
+ combined_data = pd.concat([dataset_mapping[dataset_name] for dataset_name in datasets])
43
+
44
+ fig, ax = plt.subplots(figsize=(8, 8))
45
+
46
+ centroids, labels = apply_kmeans(combined_data.values, k_value)
47
+ ax.scatter(combined_data['x'], combined_data['y'], c=labels, cmap='viridis')
48
+ ax.scatter(centroids[:, 0], centroids[:, 1], s=200, c='red', marker='X')
49
+
50
+ ax.set_xlim(0, 100)
51
+ ax.set_ylim(0, 100)
52
+ ax.set_title(f"K-means clustering result (k={k_value})")
53
+ st.pyplot(fig)
54
 
55
  if __name__ == "__main__":
56
+ main()
57
+
58
+