class 标签的数量必须大于一个
The number of class labels must be greater than one
我正在使用 Perceptron 训练鸢尾花数据集并发现以下错误。
ValueError: The number of class labels must be greater than one.
下面的代码
y = df.iloc[0:100, 4].values
y = np.where(y== 'Iris-setosa', -1,1)
X = df.iloc[0:100, [0,2]].values
ppn = Perceptron(eta0=0.1, n_iter=10)
ppn.fit(X,y)
objective 是使用萼片长度和花瓣长度为物种类型拟合数据。
我不明白这个错误。我该如何纠正?
df.head() #for reference
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
0 5.1 3.5 1.4 0.2 setosa
1 4.9 3.0 1.4 0.2 setosa
2 4.7 3.2 1.3 0.2 setosa
3 4.6 3.1 1.5 0.2 setosa
您正试图预测在您的示例中只有一个值 "setosa" 的物种。您至少需要具有不同的值。
我正在使用 Perceptron 训练鸢尾花数据集并发现以下错误。
ValueError: The number of class labels must be greater than one.
下面的代码
y = df.iloc[0:100, 4].values
y = np.where(y== 'Iris-setosa', -1,1)
X = df.iloc[0:100, [0,2]].values
ppn = Perceptron(eta0=0.1, n_iter=10)
ppn.fit(X,y)
objective 是使用萼片长度和花瓣长度为物种类型拟合数据。 我不明白这个错误。我该如何纠正?
df.head() #for reference
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
0 5.1 3.5 1.4 0.2 setosa
1 4.9 3.0 1.4 0.2 setosa
2 4.7 3.2 1.3 0.2 setosa
3 4.6 3.1 1.5 0.2 setosa
您正试图预测在您的示例中只有一个值 "setosa" 的物种。您至少需要具有不同的值。