MCPcopy Create free account
hub / github.com/Hrishikesh332/HCDS-EPD / apply_clustering

Function apply_clustering

utils.py:359–368  ·  view source on GitHub ↗
(X_scaled, algorithm, n_clusters)

Source from the content-addressed store, hash-verified

357 return pd.DataFrame()
358
359def apply_clustering(X_scaled, algorithm, n_clusters):
360 if algorithm == "K-Means":
361 clusterer = KMeans(n_clusters=n_clusters, random_state=42, n_init=10)
362 elif algorithm == "Hierarchical":
363 clusterer = AgglomerativeClustering(n_clusters=n_clusters, linkage='ward')
364 else:
365 clusterer = DBSCAN(eps=0.5, min_samples=2)
366
367 cluster_labels = clusterer.fit_predict(X_scaled)
368 return cluster_labels.astype(str)
369
370def gen_real_pred_errors(df, test_periods=6):
371 errors = []

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected