Am working on binary classification problem with 5K records. Label 1 is 1554 and Label 0 is 3558.

I did refer this post but not sure whether it is updated now or anyone has any way to compute this metrics

Currently I use logit model as shown below

model = smm.Logit(y_train, X_train_std)
y_pred = result.predict(X_test_std)
print("Accuracy is ", accuracy_score(X_test_std, y_pred))  #throws error from here and all the line below
print(classification_report(X_test_std, y_pred))
print("ACU score is ",roc_auc_score(X_test_std, y_pred))
print("Recall score is",recall_score(X_test_std,y_pred))
print("Precision score is",precision_score(X_test_std,y_pred))
print("F1 score is",f1_score(X_test_std,y_pred))

The reason why I am trying to do this is because statsmodel has p-values, coeff, intervals etc and I was hoping to get the usual metrics through scikit metrics as shown above but it isn't accepted.

On the other hand, Through scikit logistic regression I can get usual metrics and coeff, but what about p-values, conf intervals? Is there anyway to do the reverse?

Can someone help me with this?


1 Answer 1


Interpreting the code (since the error received is not mentioned), it looks like the code is passing in the X matrix and y-pred to the metrics. According to the documentation, the metrics want the y-true and y-pred. This would lead to an error mentioning incorrect dimensions.

I have used statsmodels and call scikit metrics. Many of the scikit examples, like the above documentation, show arrays being passed in, not from a specific model.

If that is not it, please post the error received.

  • $\begingroup$ Hi, thanks for the response. Upvoted. Will update the post within few hours $\endgroup$
    – The Great
    Jan 8, 2020 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.