K-Means Clustering Algorithm
Machine Learning courses with 100+ Real-time projects Start Now!!
Program 1
from sklearn.cluster import KMeans
import pandas as pd
# Sample data
data = pd.DataFrame({
"Income": [15000, 16000, 90000, 95000, 60000, 62000,65000,98000,12000],
"SpendingScore": [90, 85, 20, 15, 50, 55,54,23,94]
})
# Apply K-Means
kmeans = KMeans(n_clusters=3, random_state=42) # This sets the number of clusters to 3.
data["Cluster"] = kmeans.fit_predict(data)
print(data)
You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

