【发布时间】:2022-01-07 17:41:39
【问题描述】:
我想在使用 MinMaxScaler 对缩放数据集进行 K-means 聚类后恢复我的数据, 这是我的代码示例
copy_df=scaled_df.copy()
kmeans = KMeans(n_clusters=3, random_state=42)
kmeans.fit(features)
copy_df['Cluster'] = kmeans.predict(features)
缩放器已保存;
我试过类似的东西:x = scaler.inverse_transform(x)
与我的 scaled_df(簇号)相比,我的 copy_df 应该多一列
我想这就是我得到的原因:
ValueError: operands could not be broadcast together with shapes (3,5) (4,) (3,5)
我怎样才能恢复我的数据?
我需要获取集群的真实数据或每个特征的平均值。
【问题讨论】:
标签: python machine-learning scikit-learn k-means feature-clustering