gpt4 book ai didi

python - Scikit Learn SGDClassifier Partial_Fit 错误

转载 作者:行者123 更新时间:2023-11-30 09:21:23 24 4
gpt4 key购买 nike

我正在使用 scikit-learn 和 SGD 分类器来小批量训练 SVM。这是一个小代码片段:

for row in reader:
if row[0] in model.docvecs:
TRAINING_X.append(model.docvecs[row[0]])
TRAINING_Y.append(row[2])
if count % 10000 == 0:
np_x = np.asarray(TRAINING_X)
np_y = np.asarray(TRAINING_Y)
clf.partial_fit(np_x,np_y, np.unique(np.asarray))
TRAINING_X = []
TRAINING_Y = []
count += 1

我使用partial_fit函数读取每1000个数据点,并使用np.unique()根据documentation生成类标签。

但是,当我运行此程序时,出现以下错误:

raise ValueError("The number of class labels must be " ValueError: The number of class labels must be greater than one.

我有点困惑。我是否错误地生成了类标签?

最佳答案

partial_fit 的文档说,所有调用partial_fit 的类。可以通过np.unique(y_all)获得,其中y_all是整个数据集的目标向量

您似乎正在传递np.unique(np.asarray),这似乎不正确。

关于python - Scikit Learn SGDClassifier Partial_Fit 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36720226/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com