我正在尝试这个代码片段。我正在使用科学工具。学习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)
I am get this ->
/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])