Python Bytes - Machine Learning K Means Part 3 Cluster Predictions

Published: 23 May 2023
on channel: AC
983
15

#Coded by Andrew C
import pandas as pd
from sklearn import datasets

wine_dataset = datasets.load_wine()

wine = pd.DataFrame(wine_dataset.data, columns=wine_dataset.feature_names)

X = wine[['alcohol', 'total_phenols']]

from sklearn.preprocessing import StandardScaler

scale = StandardScaler()

scale.fit(X)

X_scaled = scale.transform(X)

from sklearn.cluster import KMeans

kmeans = KMeans(n_clusters=3)

kmeans.fit(X_scaled)

y_pred = kmeans.predict(X_scaled)

print("Cluster Predictions:")
print(y_pred)

#datascience #python #coding


Watch video Python Bytes - Machine Learning K Means Part 3 Cluster Predictions online without registration, duration hours minute second in high quality. This video was added by user AC 23 May 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 983 once and liked it 15 people.