LightGBM icon indicating copy to clipboard operation
LightGBM copied to clipboard

Default_value missing from lgb.dump output

Open rgranvil opened this issue 9 years ago • 1 comments

The output from lgb.dump no longer contains information on the default_value for missing values (either -Inf, 0, or Inf). Was this an intentional change? Can this be re-added?

Snippet of lgb.dump as of approximately June 2017:

{"tree_index":0,"num_leaves":2,
"shrinkage":1,
"has_categorical":0,
"tree_structure":{
"split_index":0,
"split_feature":0,
"split_gain":-1,
"threshold":0,
"decision_type":"no_greater",
"default_value":0,
"internal_value":0,
"internal_count":0,
"left_child":{
"leaf_index":0,
"leaf_parent":0,
"leaf_value":0.48211269768155995,
"leaf_count":0
}

Snippet of lgb.dump today:

{"tree_index":0,"num_leaves":2,
"num_cat":0,
"shrinkage":1,
"tree_structure":{
"split_index":0,
"split_feature":0,
"split_gain":-1,
"threshold":0,
"decision_type":"<=",
"internal_value":0,
"internal_count":0,
"left_child":{
"leaf_index":0,
"leaf_parent":0,
"leaf_value":0.48211269768155995,
"leaf_count":0
}

Code:

library(lightgbm)
data(agaricus.train, package = "lightgbm")
train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label)
model <- lgb.train(
  params = list(objective = "regression", metric = "l2")
  ,data = dtrain
  ,nrounds = 1
  ,min_data = 1
  ,learning_rate = 1
  ,num_leaves = 2)
writeLines(lgb.dump(model))

rgranvil avatar Aug 09 '17 15:08 rgranvil

Thanks, just fix it in the latest commit. However, the default_value is changed to default_left and missing_type. default_left=True means the missing values are in the left-child. missing_type=None means this feature doesn't have missing values. missing_type=Zero means this feature uses zero as missing values. missing_type=NaN means this feature use Na/NaN as missing values.

guolinke avatar Aug 09 '17 23:08 guolinke