Reputation: 1
I am currently doing Data modelling and I am getting an error and couldn't find a solution to it. So I am hoping I would get some help from this platform! Thanks in advance.
My code:-
from sklearn import cross_validation
from sklearn.cross_validation import cross_val_score
from sklearn.cross_validation import train_test_split
from sklearn import svm
X = np.array(observables) #X are features
y = np.array(df['diagnosis']) # y is label
X_train, y_train, X_test, y_test= cross_validation.train_test_split(X, y, test_size=0.2)
clf= svm.SVC()
clf.fit(X_train, y_train)
accuracy= clf.score(X_test, y_test)
print (accuracy)
However I get this error:
ValueError: bad input shape (114, 8)
Upvotes: 0
Views: 68
Reputation: 1163
It seems like you mixed up the order of the return values of train_test_split
, use
X_train, X_test, y_train, y_test= cross_validation.train_test_split(X, y, test_size=0.2)
instead of
X_train, y_train, X_test, y_test= cross_validation.train_test_split(X, y, test_size=0.2)
Upvotes: 2