pyGAM icon indicating copy to clipboard operation
pyGAM copied to clipboard

Fix #477: LogisticGAM.predict_proba output shape for sklearn compatib…

Open Karman580 opened this issue 9 months ago • 0 comments

Fixes #477

This PR fixes the output shape of LogisticGAM.predict_proba to ensure compatibility with the scikit-learn classifier API.

Previously, predict_proba returned only the probability of the positive class (P(y=1)) with shape (n_samples,). However, scikit-learn classifiers expect predict_proba to return a matrix of shape (n_samples, 2) containing:

[P(y=0), P(y=1)]

Changes:

  • Updated LogisticGAM.predict_proba in pygam/pygam.py to return probabilities using np.column_stack((1 - p1, p1)).
  • Updated the docstring to reflect the correct output shape.
  • Added a unit test (test_predict_proba_shape) verifying the correct probability shape and row sums.

All existing tests pass successfully.

Karman580 avatar Mar 04 '26 17:03 Karman580