Skip to content

Instantly share code, notes, and snippets.

@Dirga36
Created July 8, 2026 08:49
Show Gist options
  • Select an option

  • Save Dirga36/a17d211f696b4620064da5eb0ddd862d to your computer and use it in GitHub Desktop.

Select an option

Save Dirga36/a17d211f696b4620064da5eb0ddd862d to your computer and use it in GitHub Desktop.
from sklearn.cluster import KMeans
import pandas as pd
def classify_workload_patterns(usage_df, n_clusters=4):
"""
Cluster storage volumes by access frequency, size, and
read/write ratio to recommend appropriate storage tiers.
"""
features = usage_df[["avg_daily_accesses", "size_gb", "read_write_ratio"]]
kmeans = KMeans(n_clusters=n_clusters, random_state=42, n_init=10)
usage_df["cluster"] = kmeans.fit_predict(features)
tier_map = {
0: "hot_storage",
1: "standard_storage",
2: "infrequent_access",
3: "archive"
}
usage_df["recommended_tier"] = usage_df["cluster"].map(tier_map)
return usage_df
volumes = pd.read_csv("volume_usage_metrics.csv")
recommendations = classify_workload_patterns(volumes)
print(recommendations[["volume_id", "recommended_tier"]].head(10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment