Skip to content

[R-package] Support trees with linear models at leaves #3319

@btrotta

Description

@btrotta

PR #3299 implements trees with linear models at the leaves. I have only tested this with the Python package, and it's possible that some additional changes are needed to get it working for R. To calculate the linear model, we need a Dataset object that contains the full feature data (for numerical features, not needed for categorical), rather than just the binned data. Therefore, when we create the dataset we need to know whether linear_tree is True. In the Python interface, we first create the dataset, then call lgb.train as follows:

train_data = lgb.Dataset(x)
params = {'linear_tree'=True}
est =  lgb.train(params, train_data)

So Python doesn't know the dataset parameters (e.g. linear_tree, or max_bin, etc), until we call lgb.train. This works because the dataset is initialised in the first line, but the data isn't actually loaded until lgb.train is called. The code that handles this seems quite complex and delicate, and I had to make a couple of small changes to get it to work properly (e.g. to use the refit functionality on an existing model). So I imagine some similar tweaks would be required for the R interface.

Also, the new code requires the Eigen library for linear algebra, which is causing some issues with the R code checks in CI. See this comment for details: #3299 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions