簡體   English   中英

Python scikits - 緩沖區的維數錯誤(預期1,得2)

[英]Python scikits - Buffer has wrong number of dimensions (expected 1, got 2)

我正在嘗試此代碼段。 我正在使用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])

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM