dotnet / dotnet/machinelearning

Add Quantile Regression support to LightGbmRegressionTrainer

Open
#7,603 1 comment 7 reactions 0 assignees View on GitHub
area-Trees enhancement untriaged
Dominant language
C#
Stars
9.4k
Forks
2k
Avg merge
2d 20h
Merged PRs (30d)
11

Description

### Summary

The underlying LightGBM C++ framework natively supports quantile regression via the parameters `objective="quantile"` and `alpha=` (where alpha is the target quantile, e.g., 0.05 for the 5th percentile). However, the ML.NET `LightGbmRegressionTrainer` wrapper currently hardcodes `objective="regression"` in LightGbmRegressionTrainer.cs and does not expose the `alpha` parameter, making it impossible to train quantile regression models through the ML.NET API.

### Motivation

Quantile regression is widely used for:
- **Prediction intervals**: Training two models (e.g., α=0.05 and α=0.95) to obtain a 90% prediction interval
- **Risk modeling**: Predicting worst/best-case scenarios
- **Heteroscedastic data**: Where variance changes across the feature space

Since the native LightGBM library already supports this, exposing it through ML.NET would be a high-value, low-risk enhancement.

### Proposed Changes

1. Add a `RegressionObjective` enum to `LightGbmRegressionTrainer.Options` with values `Regression` (default) and `Quantile`
2. Add an `Alpha` property (double, default 0.5) to `LightGbmRegressionTrainer.Options`
3. Modify `CheckAndUpdateParametersBeforeTraining` to conditionally set `objective=quantile` and `alpha=`
4. Validate that `Alpha` ∈ (0, 1)
5. Add unit tests

### API Usage

```csharp
var options = new LightGbmRegressionTrainer.Options
{
Objective = LightGbmRegressionTrainer.Options.RegressionObjective.Quantile,
Alpha = 0.95,
};
var trainer = mlContext.Regression.Trainers.LightGbm(options);
```

### Scope

- No new trainer class, quantile regression produces identical tree structures and output schema
- No changes to model serialization, ONNX export, or catalog extension methods

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.