我首先将PCA应用于我的数据集,作为一种降维方法。然后对PCA数据集进行K均值聚类。
作为我项目的最后一步,我需要预测新数据的集群。
但是,当我尝试对新数据进行PCA转换时,发生了以下错误:
ValueError: n_components=2 must be between 0 and min(n_samples, n_features)=1 with svd_solver='full'我知道我们需要更多的记录来对新数据执行PCA。但是,就我的项目目标而言,我一次只得到一张唱片。
这种分析的正确过程是什么,除了这个或之外,的解决方案是什么?
谢谢
发布于 2022-07-19 13:53:44
根据这里的医生:https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html
n_components值介于0之间。和1。是使用svd_solver时的百分比。
如果您需要,这里有一个完整的PCA示例:https://scikit-learn.org/stable/auto_examples/datasets/plot_iris_dataset.html#sphx-glr-auto-examples-datasets-plot-iris-dataset-py
还有很多其他的在这个页面上的人:https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html
https://stackoverflow.com/questions/73038210
复制相似问题