Feat ordinalregression#62
Conversation
…ixedML#54) Implements the cumulative link (proportional odds) model as a new distribution class. Uses a cumulative softplus reparameterisation to enforce strict cutpoint ordering without constrained optimisation. - lightgbmlss/distributions/OrderedLogistic.py: new distribution with overrides for get_params_loss, calculate_start_values, draw_samples, and predict_dist; supports pred_type="class_probs" in addition to the standard parameters/samples/quantiles - lightgbmlss/distributions/__init__.py: register OrderedLogistic - tests/test_distributions/test_ordinal.py: 17 unit tests covering init validation, cutpoint monotonicity, forward pass, autograd, sampling, and LightGBM integration - tests/utils.py: exclude OrderedLogistic from generic fixtures - docs/examples/OrderedLogistic_Regression.ipynb: end-to-end example with simulated ordinal data, hyper_opt, evaluation (accuracy, MAE, Kendall tau, QWK), SHAP interpretability, and class probability plots
There was a problem hiding this comment.
Pull request overview
Adds ordinal regression support to lightgbmlss by introducing a new OrderedLogistic distribution built on Pyro’s cumulative-link (ordered logistic) likelihood, plus targeted unit tests and small test harness adjustments.
Changes:
- Introduces
lightgbmlss.distributions.OrderedLogisticwith cutpoint ordering enforced via cumulative softplus. - Registers the new distribution in
lightgbmlss/distributions/__init__.py. - Adds a dedicated ordinal test module and excludes
OrderedLogisticfrom generic distribution fixtures.
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
lightgbmlss/distributions/OrderedLogistic.py |
New ordinal distribution implementation (loss, start values, sampling, prediction). |
lightgbmlss/distributions/__init__.py |
Imports/exports OrderedLogistic for package registration. |
tests/test_distributions/test_ordinal.py |
Adds ordinal-specific tests for initialization, cutpoints, gradients, and objective integration. |
tests/utils.py |
Excludes OrderedLogistic from generic fixtures due to custom parameter structure. |
.gitignore |
Ignores VS Code and pytest cache artifacts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@MisterEkole Thanks for raising the PR! Really appreciate your contribution. May I ask you to look into the comments above? |
…_dist test coverage in OrderedLogistic
|
@StatMixedML I pushed fixes for the review comments — added label validation (non-integer/out-of-range targets now raise a clear error instead of silently truncating), fixed the column naming mismatch in predict_dist, cleaned up docstrings, and added tests for all predict_dist branches. Ready for another look! |
|
@copilot Review the changes by @MisterEkole |
Summary
Implements the
OrderedLogisticdistribution for ordinal regression (closes #54).Uses the cumulative link (proportional odds) model via Pyro's
OrderedLogisticdistribution. Cutpoint monotonicity is enforced through a cumulativesoftplus reparameterisation, keeping all K tree outputs unconstrained while guaranteeing strict ordering at all times.
Changes
lightgbmlss/distributions/OrderedLogistic.py— new distribution classlightgbmlss/distributions/__init__.py— register distributiontests/test_distributions/test_ordinal.py— 17 unit teststests/utils.py— exclude from generic fixturesdocs/examples/OrderedLogistic_Regression.ipynb— end-to-end examplenotebook
Test plan
pytest tests/test_distributions/test_ordinal.py)pytest tests/test_distributions/)