SHAPforxgboost icon indicating copy to clipboard operation
SHAPforxgboost copied to clipboard

{lightgbm} v4.0.0 is coming

Open jameslamb opened this issue 3 years ago • 2 comments

👋 Hello! I'm James Lamb, one of the maintainers of LightGBM.

(@mayer79 and I have talked extensively over in LightGBM, but I haven't met the other maintainers/contributors here).

We were excited to see {SHAPforxgboost} show up as a "reverse suggest" at https://cran.r-project.org/web/packages/lightgbm/index.html. If I remember correctly, I think this package was our first reverse dependency after getting to CRAN. Thanks so much for making it easier for some R users to work with {lightgbm} models! I want to do what I can to support you all.

I wanted to let you know that the next release of LightGBM (the entire project, including the R package) will be a major version release with significant breaking changes. See this discussion of v4.0.0: https://github.com/microsoft/LightGBM/issues/5153. We don't have a planned date for that release yet, as we have been struggling from a lack of maintainer attention / activity. But I expect it will be months not weeks from now.

Please open issues at https://github.com/microsoft/LightGBM/issues if there's anything we could do to make {lightgbm} easier to use with {SHAPforxgboost}.

(@mayer79 I know I owe you an answer on https://github.com/microsoft/LightGBM/issues/5223... I'm doing that next 😁 )

I'm opening this issue mainly to ask a question. In this period prior to v4.0.0, I'm willing to contribute and maintain patches that make {SHAPforxgboost} compatible with the latest release of {lightgbm} on CRAN (v3.3.2) and the upcoming release (v4.0.0) so that the next release of {lightgbm} isn't disruptive to you.

Are you open to such contributions?

Thanks for your time and consideration.

jameslamb avatar Jul 19 '22 03:07 jameslamb

@jameslamb : Thanks! In "shapviz", that uses LGB as minimal "Enhances" dependency, I am using the snippet in https://github.com/mayer79/shapviz/blob/main/R/shapviz.R

if (!requireNamespace("lightgbm", quietly = TRUE)) {
    stop("Package 'lightgbm' not installed")
  }

# Switch for different versions of predict.lgb.Booster()
  is_v4 <- utils::packageVersion("lightgbm") >= 4
  has_type <- "type" %in% names(formals(utils::getS3method("predict", "lgb.Booster")))
  if (is_v4 || has_type) {
    S <- stats::predict(object, newdata = X_pred, type = "contrib", ...)
  } else {
    S <- stats::predict(object, X_pred, predcontrib = TRUE, ...)
  }

I think that this will deal with the change from data to newdata and the type for recent versions of LGB. Actually, the condition is_v4 is redundant, but it is easier to understand than has_type. We can add this to SHAPforxgboost as well.

I can open the PR here.

mayer79 avatar Jul 19 '22 04:07 mayer79

Ok sure, excellent! Thanks very much for that. I remember you'd mentioned that plan in https://github.com/microsoft/LightGBM/pull/5133#issuecomment-1154781991 but wasn't sure it has happened yet.

If any other compatibility issues come up, please feel free to @ me. I want to help make the transition to v4.0 as easy as possible.

jameslamb avatar Jul 19 '22 04:07 jameslamb

I'm not sure why #32 was closed back in 2022, but looks like the issues it tried to prevent were reported and then fixed in almost exactly the same way a few months ago, in #41.

Either way, I don't think this issue needs to be open any more... LightGBM v4.0.0 has been out for a while, and in fact is now at v4.4.0 on CRAN.

jameslamb avatar Jun 21 '24 06:06 jameslamb