autogluon / autogluon/autogluon
Support for ordinal regression problems
- Dominant language
- Python
- Stars
- 10.7k
- Forks
- 1.2k
- Avg merge
- 21h 29m
- Merged PRs (30d)
- 57
Description
Suggest adding support for ordinal regression (classification) problems: regression + optimized rounder
1. Train a regression model.
2. Get regression results on validation set and test set.
```python
# Let y_val be labels of validation set.
y_val_pred = predictor.predict(valid_data)
y_test_pred = predictor.predict(test_data)
```
3. Implement an optimized rounder to minimize the objective loss (in the following case, quadratic weighted kappa)
```python
from functools import partial
import numpy as np
import scipy as sp
from sklearn.metrics import cohen_kappa_score
class OptimizedRounder:
def __init__(self, classes):
classes.sort()
self.classes = classes
self.coef_ = 0
def to_bins(self, y_reg, coef):
coef.sort()
bin_indices = np.digitize(y_reg, coef)
y_class = [self.classes[i] for i in bin_indices]
return y_class
def _kappa_loss(self, coef, y_reg, y):
y_class = self.to_bins(y_reg, coef)
loss = cohen_kappa_score(y, y_class, weights='quadratic')
return -loss
def fit(self, y_reg, y):
loss_partial = partial(self._kappa_loss, y_reg=y_reg, y=y)
initial_coef = [(self.classes[i-1] + self.classes[i])/2 for i in range(1, len(self.classes))]
self.coef_ = sp.optimize.minimize(loss_partial, initial_coef, method='nelder-mead')
def predict(self, y_reg, coef):
return self.to_bins(y_reg, coef)
def coefficients(self):
return self.coef_['x']
```
Fit using validation set and predict.
```python
optR = OptimizedRounder([0, 1, 2, 3, 4]) # initialize with class labels
optR.fit(y_val_pred, y_val)
coef = optR.coefficients()
y_test_pred_final = optR.predict(y_test_pred, coef)
```
Contributor guide
Research direction
The issue names no repository files or tests; start by locating the tabular predictor entry points behind predictor.predict and the existing problem-type handling. Review how validation and test predictions are produced, then define what ordinal regression support and optimized-rounder evaluation must expose, including the quadratic weighted kappa objective and final class predictions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, scikit-learn
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100