-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Binary cell type decisions lead to np.AxisError in predict_labels_and_prob #17
Comments
@chbeltz, thx a lot!! will check and let you know soon. |
@chbeltz , can I ask why you set the scores of the opposite class to all 0. As I understand, the emulated score matrix can be simply stacked by column-binding the |
@ChuanXu1 Sure, it could. However I did not see any reason to believe that would be superior. In fact I did not see anything in the docs leading me to lean either way, seeing as the relative difference in certainty between predictions would remain the same. Is there anything making your version preferable in your opinion? |
@chbeltz, in a binary case, even with the 'ovr' mode, the classifier outputs the intercept and coefficients for the second class (.classes_[1]). For the first class, the decision score is not output, but it is actually the negative form of the score in the second class. Activated by the sigmoid further, the probability of the first class will be 1 - probability_of_2nd_class. If you turn the opposite to 0, you will get all probabilities of 0.5. Wdyt? |
Ah, makes sense. Did not think of that. Thanks for the fix. |
When trying to make a binary cell type decision using CellTypist, I encountered an AxisError in line 131 of models.py, caused by scores.argmax(axis=1). When making binary decisions, sklearn's LogsticRegression.decision_function yields not an ndarray of shape (n_samples, n_classes) but of (n_samples,), making axis=1 and argmax in general problematic.
My suggested solution is first checking the number of dimensions in the output of decision_function and if it is equal to 1, as with binary decisions, emulating the output format expected by CellTypist, conserving the difference in confidence scores between the two available classes for every cell. This is implemented in #18.
The text was updated successfully, but these errors were encountered: