gpt4 book ai didi

Python scikits - 缓冲区的维数错误(预期为 1,得到 2)

转载 作者:太空宇宙 更新时间:2023-11-03 14:32:38 25 4
gpt4 key购买 nike

我正在尝试这段代码。我正在使用 scikits.learn 0.8.1

from scikits.learn import linear_model
import numpy as np
num_rows = 10000
X = np.zeros([num_rows,2])
y = np.zeros([num_rows,1])
# assume here I have filled in X and y appropriately with 0s and 1s from the dataset
clf = linear_model.LogisticRegression()
clf.fit(X, y)

我明白了 -->

/usr/local/lib/python2.6/dist-packages/scikits/learn/svm/liblinear.so in scikits.learn.svm.liblinear.train_wrap (scikits/learn/svm/liblinear.c:992)()

ValueError: Buffer has wrong number of dimensions (expected 1, got 2)

这里有什么问题吗?

最佳答案

已解决。错误是由于:

y = np.zeros([num_rows,1])

应该是:

y = np.zeros([num_rows])

关于Python scikits - 缓冲区的维数错误(预期为 1,得到 2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8123524/

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