I'm trying to apply a multi-label classification. The shapes are:
x_train.shape
(3975, 3788)
y_train.shape
(3975, 66)
x_test.shape
(994, 3788)
y_test.shape
(994, 66)
When I try to train, it gives the following error:
ValueError: bad input shape (3975, 66)
Any way to solve that? Here is the code:
sgd = SGDClassifier()
lr = LogisticRegression(solver='lbfgs')
svc = LinearSVC
def j_score(y_true, y_pred):
jaccard = np.minimum(y_true, y_pred).sum(axis =1)/np.maximum(y_true, y_pred).sum(axis =1)
return jaccard.mean()*100
def print_score(y_pred, clf):
print('Clf: ', clf.__class__.__name__)
print('Jaccard score: {}'.format(j_score(y_test, y_pred)))
print('----')
for classifier in [sgd, lr, svc]:
clf = OneVsOneClassifier(classifier)
clf.fit(x_train, y_train) #Here is the error indicator
y_pred = clf.predict(x_test)
print_score(y_pred, classifier)