7

Working with lightGBM on Python and as it doesn't have enough documentation, I am unable to tackle this issue since a while. Please help me out with these few questions if anyone with lgb experience available here.

  1. lgb.cv doesn't work when having a continuous target variable. Why?
  2. When having objective "regression" can I have boosting_type as "rf" (random Forest)? This issue opened here on the library kinda confirms that I can. Thoughts?
  3. Below is the piece of code that works completely fine if I replace the "rf" parameter with "gbdt"

    params = {
            "objective" : "regression", "metric" : "rmse",
            "num_leaves" : 150, "learning_rate" : 0.05,
            "bagging_fraction" : 0.6, "feature_fraction" : 0.7,
            "bagging_frequency" : 1, "bagging_seed" : 2018,
            "verbosity" : -1, 'max_depth':-1,
            "min_child_samples":20, "boosting":"rf"}
    
    model = lgb.train(params, lgtrain, 1000, valid_sets=[lgval],
            early_stopping_rounds=20, verbose_eval=20, evals_result=evals_result)
    

On having random forest boosting method, I get the following error -

LightGBMError: b'Check failed: config->bagging_freq > 0 && config->bagging_fraction < 1.0f && config->bagging_fraction > 0.0f at /home/travis/build/Microsoft/LightGBM/python-package/compile/src/boosting/rf.hpp, line 29 .\n'
desertnaut
  • 57,590
  • 26
  • 140
  • 166
Krithi07
  • 481
  • 2
  • 7
  • 18
  • https://stackoverflow.com/questions/49774825/python-lightgbm-cross-validation-how-to-use-lightgbm-cv-for-regression Adding stratified=False works. I guess this link here answers my first question – Krithi07 May 26 '18 at 19:16

1 Answers1

4

As the error suggests, the code fails because the check does not pass. The reason is very simple- the name of the frequency variable is bagging_freq instead of bagging_frequency.

And you have already found the right answer to the first question about lgb.cv configuration for regression.

Mischa Lisovyi
  • 3,207
  • 18
  • 29