JUNGU commited on
Commit
77631e1
·
1 Parent(s): b73f6ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -7,17 +7,16 @@ from sklearn.cluster import KMeans
7
  # Generate the datasets
8
  np.random.seed(42)
9
  num_samples = 30
10
- traffic_centers = [(20, 20), (80, 80)]
11
- nature_centers = [(0, 80), (80, 0)]
12
- population_centers = [(0, 0), (50, 50), (100, 100)]
13
 
14
- traffic_data = [np.random.normal(center, 10, (num_samples, 2)) for center in traffic_centers]
15
- nature_data = [np.random.normal(center, 10, (num_samples, 2)) for center in nature_centers]
16
- population_data = [np.random.normal(center, 10, (num_samples, 2)) for center in population_centers]
17
 
18
- traffic_df = pd.DataFrame(np.vstack(traffic_data), columns=["x", "y"])
19
- nature_df = pd.DataFrame(np.vstack(nature_data), columns=["x", "y"])
20
- population_df = pd.DataFrame(np.vstack(population_data), columns=["x", "y"])
 
 
21
 
22
  def apply_kmeans(data, k):
23
  kmeans = KMeans(n_clusters=k, random_state=42).fit(data)
 
7
  # Generate the datasets
8
  np.random.seed(42)
9
  num_samples = 30
 
 
 
10
 
11
+ traffic_data = np.random.uniform(0, 100, (num_samples * len(traffic_centers), 2))
12
+ nature_data = np.random.uniform(0, 100, (num_samples * len(nature_centers), 2))
13
+ population_data = np.random.uniform(0, 100, (num_samples * len(population_centers), 2))
14
 
15
+ traffic_df_uniform = pd.DataFrame(traffic_data, columns=["x", "y"])
16
+ nature_df_uniform = pd.DataFrame(nature_data, columns=["x", "y"])
17
+ population_df_uniform = pd.DataFrame(population_data, columns=["x", "y"])
18
+
19
+ traffic_df_uniform.head(), nature_df_uniform.head(), population_df_uniform.head()
20
 
21
  def apply_kmeans(data, k):
22
  kmeans = KMeans(n_clusters=k, random_state=42).fit(data)