import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
iris=pd.read_csv(“D:\Test\iris1.csv”)
iris.describe()
from sklearn.preprocessing import LabelEncoder
iris[“style”]=LabelEncoder().fit_transform(iris[“style”].values.reshape(-1,1))
from sklearn.preprocessing import StandardScaler
column_list=[“sl”,”sw”,”pl”,”pw”]
for i in range(len(column_list)):
iris[column_list[i]]=StandardScaler().fit_transform(iris[column_list[i]].values.reshape(-1,1))
x=iris[[“sl”,”sw”,”pl”,”pw”]]
y=iris[“style”]
#KMeans聚类
from sklearn.cluster import KMeans
kmeans=KMeans(n_clusters=4)
kmeans.fit(x)
pre_label=kmeans.labels_
#print(pre_label)
x0=x[pre_label==0]
x1=x[pre_label&#