1
$\begingroup$

with LinearSVC, I get an accuracy off 0.89:

linearSVC = LinearSVC().fit(X_train, y_train)
y_pred = linearSVC.predict(X_test)
print('accuracy', np.sum(y_pred == y_test) / y_test.shape[0])

Because I need online training, I tried the same with SGDClassifier:

sgd = SGDClassifier().fit(X_train, y_train)
y_pred = sgd.predict(X_test)
print('accuracy', np.sum(y_pred == y_test) / y_test.shape[0])

but now I get 0.004 - what am I missing here? The shape of X_train is (21519, 8255). Of course I do not expect the exact same accuracy, but SGDClassifier basically gets nothing right...

EDIT

I just found the reason - although I do not understand why there is SUCH a difference: I had an amount feature which includes numbers (= currency amount). With it included, the SGDClassifier performs horrible (= 0.3%), when transforming it to positive/negative, I get around 90% accuracy.

$\endgroup$
  • $\begingroup$ Try to normalize your features (X_train and X_test) before fiting/predicting with the SGDClassifier $\endgroup$ – xboard Mar 3 '19 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.