如何从 R 中的 lightgbm 模型绘制决策树?

aSR*_*SRA 7 r lightgbm

如何绘制 lightgbm 决策树?我到处搜索但找不到解决方案。这是该模型的示例:

data(agaricus.train, package = "lightgbm")
train <- agaricus.train

dtrain <- lgb.Dataset(train$data, label = train$label)

data(agaricus.test, package = "lightgbm")

test <- agaricus.test

dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label)

params <- list(objective = "regression", metric = "l2")

valids <- list(test = dtest)

model <- lgb.train(params,
               dtrain,
               100,
               valids,
               min_data = 1,
               learning_rate = 1,
               early_stopping_rounds = 10)
Run Code Online (Sandbox Code Playgroud)