首页 > 解决方案 > ValueError:信息、冗余和重复特征的数量必须总和小于总特征的数量

问题描述

我正在尝试使用以下代码为分类模型生成数据集:

from sklearn.datasets import make_classification
import matplotlib.pyplot as plt

X, y = make_classification(n_features=2)

plt.plot(X, y)
plt.show()

但这会返回错误:

raise ValueError("Number of informative,redundant and repeat") ValueError: 提供信息的、冗余的和重复的特征的数量总和必须小于总特征的数量

标签: pythonmachine-learningscikit-learn

解决方案


from sklearn.datasets import make_classification
import matplotlib.pyplot as plt

X, y = make_classification(n_features=2, n_informative=1, n_redundant=0, n_classes=1)
plt.plot(X,y)
plt.show()

在此处输入图像描述


推荐阅读