ValueError:scikit中的错误输入形状()学习

时间:2014-07-12 15:14:44

标签: python scipy data-mining scikit-learn

我试图运行以下代码,该代码使用交叉验证来评估Scikit中的线性回归方法。

X_train, X_test, y_train, y_test = cross_validation.train_test_split(train, outcomes == 't', test_size=0.4, random_state=0)
X_test.shape , y_test.shape
model = LogisticRegression(C=0.1)
model.fit(X_train[:X_train.shape[0]/2], y_train[:y_train.size/2] == 't')
preds1 = model.predict_proba(X_test)[:, 1]
model.fit(X_train[(X_train.shape[0]/2 + 1):], y_train[(y_train.size/2) +1 :] == 't')
preds2 = model.predict_proba(X_test)[:, 1]
preds = (preds1+preds2)/2

at" model.fit(X_train [:(X_train.shape [0] / 2],y_train [:y_train.size / 2] ==' t')" 。 我收到错误说:

Traceback (most recent call last):
  File "ROC.py", line 137, in <module>
    model.fit(X_train[:X_train.shape[0]/2], y_train[:y_train.size/2] == 't')
  File "/usr/local/lib/python2.7/dist-packages/sklearn/svm/base.py", line 674, in fit
    y_ind = self._enc.fit_transform(y)
  File "/usr/local/lib/python2.7/dist-packages/sklearn/preprocessing/label.py", line 124, in fit_transform
    y = column_or_1d(y, warn=True)
   File "/usr/local/lib/python2.7/dist-packages/sklearn/utils/validation.py", line 310, in column_or_1d
    raise ValueError("bad input shape {0}".format(shape))
ValueError: bad input shape ()

这是什么原因?我该如何解决这个问题?

0 个答案:

没有答案