2011-11-14 8 views
3

이 코드 스 니펫을 사용하려고합니다. 나는 scikits.learn 0.8.1Python scikits - 버퍼의 치수 수가 잘못되었습니다 (예상 1, 획득 2)

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) 

?

+0

이 그것을 배열로 인수를 금지 할 때 NumPy와에서 일반 오류 인 오류는 것이 었습니다. – smci

답변

5

해결되었습니다. 그것은 있었어야

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

:

y = np.zeros([num_rows]) 
+3

아니면 그냥'np.zeros (num_rows)'. –