Update app.py
Browse files
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 =
|
15 |
-
nature_data =
|
16 |
-
population_data =
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
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)
|