我想取消这个警告...
k_clust = KMeans(n_clusters=4, random_state= 35, n_init=1).fit(df_normal)
palette = sns.color_palette("tab10")
sns.pairplot(new_df, hue="clusters", palette=palette)
簇的数量只有 4 个,而调色板“tab10”有超过 4 个颜色。我使用这个调色板是因为它具有独特的颜色蓝色、绿色、橙色和红色。
输出为:
C:\Users\....\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\seaborn\axisgrid.py:1507: UserWarning: The palette list has more values (10) than needed (4), which may not be intended.
func(x=vector, **plot_kwargs)
尝试在运行聚类算法之前放置这段代码。它依赖于警告控制库:
import warnings
# Suppress seaborn UserWarning
warnings.filterwarnings("ignore", category=UserWarning)